Why convert JSON to XML at all?
JSON won the API era, but XML never left the building: SOAP services, RSS and Atom feeds, SVG images, Office documents, SAML assertions, Maven and Android configuration, and a generation of enterprise systems still speak it natively. When a modern JSON-producing system has to hand data to any of those, someone writes the conversion — and writes it carefully, because the two formats do not model data the same way. JSON has objects, arrays and scalars. XML has elements, attributes, text and namespaces. A converter's job is to pick the predictable mapping and to be honest about the places where the mapping is a convention rather than a law.
The mapping rules used here
| JSON | XML |
|---|---|
| Object key | Child element with that name |
| Array | The key's element wraps one child element per item, using the array-item name (default item) |
| String / number / boolean | Text content, with &, < and > escaped |
| null | Empty element with nil="true", so it stays distinct from an empty string |
| Key that is not a legal XML name | Illegal characters replaced with _ (digit-first names get an _ prefix) — and every rename is reported above the result |
| Whole document | Wrapped in one root element (default root) under an <?xml version="1.0" encoding="UTF-8"?> declaration |
Two consequences deserve attention. First, XML produced this way is element-only: nothing becomes an attribute, because JSON gives no signal about which keys deserve to be attributes, and inventing that distinction would change the document's meaning. Second, a top-level JSON array has no key to name its wrapper, so the root element holds the item elements directly — well-formed, and exactly what most XML pipelines expect.
How to use this tool
- Paste JSON, upload a .json file, or press Load sample. Conversion also runs automatically as you type.
- Name the root element and the array-item element if the defaults (
root/item) do not match your target schema. - Read the rename report if one appears — it lists every key that could not be used as an XML name unchanged.
- Copy, download or print the XML. If the input is not valid JSON, you get the exact line and column of the error instead of a half-converted document.
Example
This JSON:
{"user":{"name":"Ada & Co","roles":["admin","editor"],"score":null}} becomes:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<user>
<name>Ada & Co</name>
<roles>
<item>admin</item>
<item>editor</item>
</roles>
<score nil="true"/>
</user>
</root>