About the JSON to XML Converter
JSON and XML model data differently, so a converter has to choose rules. This one maps each object key to an element of the same name, each array to a repeated element, and each primitive to text content. Null values become empty self-closing elements. Because the top level of a JSON document may be an array or a bare value, the output is wrapped in a root element whose name you choose, and array items get a name you choose too.
Key names that are not legal XML names, for example those starting with a digit or containing spaces, are rewritten by replacing the offending characters with underscores and prefixing an underscore where needed. Text content is escaped, so angle brackets and ampersands in your strings come out as entities and the result is always parseable.
The converter does not emit attributes, because JSON has no way to say which values should be attributes. If the receiving system expects a specific schema, convert first and then adjust the structure in the XML Formatter. For the reverse direction use XML to JSON.
How to use
- Paste JSON on the left.
- Set Root element and, for arrays, Array item element to the tag names you need.
- Copy or download the XML on the right. Swap sends it to XML to JSON to check the round trip.
Common questions
- How are JSON arrays represented in the XML?
- Each item becomes a separate element with the same name. An array under the key "tags" becomes several
<tags>elements. A top-level array uses the item name you set in the toolbar. - Can I get JSON keys as XML attributes?
- No. There is no information in JSON to decide which keys should be attributes, so every key becomes a child element.
- What happens to keys with spaces or special characters?
- They are converted to valid element names by replacing invalid characters with underscores. "first name" becomes
first_name. - Is the XML declaration included?
- Yes, the output starts with
<?xml version="1.0" encoding="UTF-8"?>.