Convert JSON to XML
More data converters: JSON to Excel · JSON to CSV · CSV to JSON · Excel to JSON · XML to JSON · XML to Excel · YAML to JSON · JSON Formatter
How to Convert JSON to XML
Any JSON — an object, a list or the output of XML to JSON.
Leave Root element on automatic to use the single top-level key, or type the name your system expects.
The XML starts with a UTF-8 declaration and is indented for reading, or on one line if you choose.
How JSON becomes XML
The rules this converter uses
| JSON | XML |
|---|---|
"title": "Rain" | <title>Rain</title> |
"book": [{…}, {…}] | Two <book> elements next to each other |
| A list at the top level | <root> with one <item> per entry — both names can be changed |
"@id": "bk1" | The attribute id="bk1" |
"#text": "5" | Text inside the element |
null or "" | An empty element, <note/> |
- Root element on automatic: if the JSON is an object with one key, such as
{"catalog": {…}}, that key becomes the root. Otherwise the root is<root>. - Invalid names are fixed: XML element names cannot contain spaces or start with a digit, so
"first name"becomes<first_name>and"1st"becomes<_1st>. - Special characters &, < and > are escaped, and control characters that XML does not allow are removed, so the result always parses.
- Lists inside lists are wrapped in the list item name, because XML has no unnamed groups.
To go back from XML, use XML to JSON. To check the JSON first, use the JSON formatter.
Frequently Asked Questions
Is the JSON sent to your server?
No. The XML is generated by JavaScript in your browser. Nothing is uploaded or stored.
How do I create XML attributes?
Start the key with @, for example "@id": "42". It becomes id="42" on the element. A "#text" key becomes the element text.
What is the root element?
XML needs exactly one outer element. On automatic, a single top-level key is used; otherwise it is called root. You can type any name.
Will the XML be valid?
Yes. Names are made XML-safe, special characters are escaped and invalid control characters are removed, so the result is well-formed XML.