How to use JSON to XML
- Paste your JSON into the input box.
- Optionally type a root element name, choose the indentation, and decide whether to add the XML declaration.
- Read the XML in the output box; errors in the JSON show the line and column.
- Click Copy or Download to save data.xml.
Features
- Keys become element names; invalid name characters are replaced with underscores
- Arrays become repeated elements with the same name
- Text is escaped (&, <, >) so the XML is well-formed
- Choose root name, 2 spaces, 4 spaces or tab, and the XML declaration
- Runs in your browser, so the JSON is never uploaded
Supported formats and limits
- Maximum input: 10,000,000 characters
Examples
| Input | Result |
|---|---|
| {"name":"Ana","age":30} | <?xml version="1.0" encoding="UTF-8"?> <root> <name>Ana</name> <age>30</age> </root> |
| {"tags":["a","b"]} | <doc> <tags>a</tags> <tags>b</tags> </doc> — Root element set to "doc", declaration off. |
| {"note":"A & B"} | <note>A & B</note> |
Limitations
- JSON has no attributes, so every value becomes an element; nothing is written as an XML attribute.
- A key that is not a valid XML name (for example "first name" or "1st") is renamed ("first_name", "_1st").
- null becomes an empty element, and true, false and numbers are written as text, so types are not preserved.
Learn more
XML and JSON both describe structured data, but they model it differently. JSON has objects, arrays and a few value types. XML has a single root element, nested elements, attributes and text, and element names must follow strict naming rules.
That mismatch means any JSON to XML converter has to make choices. Here, an object key becomes an element name, an array becomes a run of elements sharing the same name, and primitive values become text. Because XML requires exactly one root element, a wrapper such as <root> is added when the JSON does not already have a single top-level key.
The characters &, < and > have special meaning in XML, so they are escaped in the output. The result is well-formed, meaning any XML parser can read it, but it does not follow any particular schema. If a system expects a specific XML structure, treat this output as a starting point.
Frequently asked questions
How are arrays converted?
Each item becomes an element with the name of the array key, so {"tags":["a","b"]} gives two <tags> elements. A top-level array is wrapped in <root> with <item> elements.
What root element is used?
If the JSON is an object with one key, that key is the root. Otherwise the content is wrapped in <root>, or in the name you type.
Does it create XML attributes?
No. Everything becomes element content. If you need attributes, edit the XML afterwards.
Is my JSON uploaded?
No. The conversion runs in your browser.
Sources
- RFC 8259, The JavaScript Object Notation (JSON) Data Interchange Format
- Extensible Markup Language (XML) 1.0, W3C Recommendation
Last reviewed: September 30, 2026