JSON to XML
Convert JSON to XML online for free. Paste JSON and get well-formed XML instantly, in your browser.
Suggested tools
About JSON to XML
JSON to XML converts JSON into well-formed, indented XML for APIs, legacy systems and configuration files. Objects become elements, arrays become repeated elements, and special characters are escaped correctly.
XML needs exactly one root element: if your JSON has a single top-level key it becomes the root; otherwise the data is wrapped in <root> (and array items in <item>). Keys that are not valid XML names are made safe automatically. It runs entirely in your browser, so nothing you paste is uploaded.
How to use JSON to XML
- Paste JSON, upload a .json file or click Sample.
- Press Convert.
- Copy or download the XML.
Key features
- Well-formed, indented XML output
- Arrays become repeated elements
- Automatic root element when needed
- Invalid tag names made safe
Example
Arrays become repeated elements; the single top-level key becomes the root element.
{"order":{"id":5001,"customer":"Ravi Shah","items":[{"sku":"PEN-01","qty":2},{"sku":"NB-07","qty":1}]}}<order>
<id>5001</id>
<customer>Ravi Shah</customer>
<items>
<sku>PEN-01</sku>
<qty>2</qty>
</items>
<items>
<sku>NB-07</sku>
<qty>1</qty>
</items>
</order>When to use JSON to XML
- Sending JSON data to an older API or system that only accepts XML.
- Generating XML test data from JSON fixtures.
- Converting configuration between formats.
Tips and common problems
- Use keys that are valid XML names (letters first, no spaces) to avoid automatic renaming.
- Prefix keys with @_ to create attributes.
- Wrap your data in one top-level key to control the root element name.
Frequently asked questions
Prefix a key with @_ — for example {"book": {"@_id": "7", "title": "X"}} gives <book id="7"><title>X</title></book>.
Your JSON had more than one top-level key (or was an array), and XML allows only one root element.
Yes, with XML to JSON.
Guides
- How to Convert JSON to CSV — How to convert JSON to CSV: how arrays of objects map to rows and columns, how nested objects are flattened, and how to avoid losing data.
- JSON vs XML vs YAML — JSON vs XML vs YAML compared: strengths, weaknesses and best uses, to help you choose the right data format for APIs, config files and documents.