Why use this converter
Attribute support
Keys prefixed with @ (configurable) become XML attributes instead of child elements. Useful for metadata like @id, @type, @href.
Array handling
Each array item is rendered with the parent key as the element name. "roles":["a","b"] becomes two <roles> elements.
Proper escaping
All text content is escaped for XML: &, <, >, ", '. Output is always well-formed XML.
Conversion explained
1. Parse JSON
Input is parsed into a JavaScript value. Invalid JSON produces a clear error.
2. Walk and emit
The converter walks the value recursively. For each object, it separates attribute keys (prefixed with @) from child element keys, then emits the appropriate XML.
3. XML declaration
The output begins with <?xml version="1.0" encoding="UTF-8"?> by default.
JSON to XML Converter — frequently asked questions
How are arrays represented in XML?
Each item in a JSON array becomes a separate XML element with the parent key as its name. For example, "tags":["a","b","c"] becomes three <tags> elements.
How do I add XML attributes?
Use the @ prefix (configurable) on a key. For example, {"user":{"@id":"123","name":"Ada"}} produces <user id="123"><name>Ada</name></user>.
Why doesn't XML support all JSON types directly?
XML is a markup language, not a data format. It has no native concept of null, boolean, or number types — everything is text. JSONLab renders null as null="true" attribute, booleans as their string form.
Can I convert XML back to JSON?
Yes — use the XML to JSON tool. The conversion is reversible for the subset of XML that JSONLab produces.
You might also like
XML to JSON
Convert XML to JSON format
JSON to YAML
Convert JSON to YAML format
JSON to CSV
Convert JSON array to CSV spreadsheet
JSON to TypeScript
Generate TypeScript interfaces from JSON
JSON Validator
Validate JSON syntax with detailed error messages
JSON Formatter
Format and beautify JSON with custom indentation