JSON to XML converter
Turn JSON data into valid XML.
Runs in your browser. Nothing you type is sent anywhere.
- Custom root element
- Always well-formed
- Nothing uploaded
How to convert JSON to XML
- Paste or upload your JSON.
- Type a name for the root element.
- Copy the XML or download it.
Example: JSON in, XML out
| JSON | XML |
|---|---|
| {"name":"Sam"} | <root><name>Sam</name></root> |
| {"@_id":"5","#text":"Widget"} | <root id="5">Widget</root> |
| {"tag":["a","b"]} | <root><tag>a</tag><tag>b</tag></root> |
How JSON keys become tag names
- A character XML does not allow in a name, such as a space, is replaced with _, so "first name" becomes first_name.
- A key starting with a digit gets a leading _ added, since XML names cannot start with a number.
- A key that collides with a renamed one gets a number appended, so a second first_name becomes first_name_2.
Where JSON to XML is useful
- Feeding data into an older system or API that only accepts XML.
- Building a small feed, like an RSS-style file, from a JSON data source.
- Checking how a JSON payload would look as a SOAP or legacy XML request body.
Limits to be aware of
- A JSON null becomes an empty element, since XML has nothing that means exactly null.
- Keys that differ only by case, like Name and name, become two different tags, since XML tag names are case-sensitive.
- Numbers and booleans are written as plain text in the XML. A reader has to know to parse them back into their original type.
JSON to XML FAQ
How are arrays written in XML?
Each item in an array becomes a repeated element named after its key. An array at the top level is wrapped in item elements under the root.
How do I create attributes?
Start a key with @_, such as "@_id": 5, and it becomes an attribute of its parent element. This matches the output of the XML to JSON converter.
What if a key is not a valid XML tag name?
Characters XML does not allow in names, such as spaces, are replaced with _, and a name that starts with a digit gets a _ added in front. So "first name" becomes first_name.
Can I round-trip a file through XML to JSON and back?
Yes. JSON produced by the XML to JSON converter with attributes on, including its @_ keys and #text values, converts back into matching XML here.
What happens to a JSON array of plain values, like a list of tags?
Each value becomes its own repeated element named after the array's key, for example a tags array of ["a","b"] under key tag becomes <tag>a</tag><tag>b</tag>.
Does the output include an XML declaration?
Yes. Every result starts with <?xml version="1.0" encoding="UTF-8"?> on its own line.
Does it escape special characters like < or & inside text?
Yes. Any character that would otherwise break XML syntax inside text or an attribute value is escaped automatically, so the result always parses back cleanly.
Can I nest an object inside an array inside another object?
Yes. Any depth and mix of objects and arrays converts, with each level becoming its own set of nested elements.