Paste JSON and get clean, well-formed XML instantly. Choose the root element name, map @ keys to attributes, decide how arrays are written, then copy or download the result. Nothing leaves your browser.
Last updated:
1
XML output
Converts automatically as you type.
Advertisement
Advertisement
How to use the JSON to XML Converter
Paste your JSON into the left box, upload a .json file, or click Sample.
Set the root element name. If your JSON has a single top-level key, it can be used as the root automatically.
Choose how arrays are written: repeated elements with the key's name (<tag>a</tag><tag>b</tag>) or wrapped in a parent with item elements.
Add attributes by prefixing keys with @, for example {"book": {"@id": "b1", "title": "…"}}.
Copy or download the XML.
How JSON is mapped to XML
JSON
XML
{"name": "Ann"}
<name>Ann</name>
{"user": {"@id": 7, "name": "Ann"}}
<user id="7"><name>Ann</name></user>
{"price": {"@currency": "EUR", "#text": 9.5}}
<price currency="EUR">9.5</price>
{"tag": ["a", "b"]}
<tag>a</tag><tag>b</tag>
{"tag": ["a", "b"]} with Wrap arrays
<tag><item>a</item><item>b</item></tag>
{"note": null} or {"note": ""}
<note/>
{"#cdata": "a < b"}
<![CDATA[a < b]]>
{"#comment": "generated"}
<!--generated-->
Numbers and booleans are written as text (44.95, true) because XML has no data types of its own; a schema (XSD) is what gives XML values a type. An empty array produces no element at all, since XML has no way to say "an empty list" without a wrapper.
Tips for clean XML
Pick meaningful names. Rename the root and array item elements to match your domain, for example catalog and book.
Use attributes for metadata such as IDs, units and language codes, and elements for the actual content.
Namespaces can be added with an attribute key such as "@xmlns": "urn:example" or "@xmlns:xsi".
Each object key becomes an element, its value becomes the element's content, and nested objects become nested elements. Keys that start with @ become attributes, a #text key becomes the element's text, and null becomes an empty element such as <name/>.
How are JSON arrays converted to XML?
By default every array item becomes a repeated element with the array's key as its name, so {"tag": ["a", "b"]} becomes <tag>a</tag><tag>b</tag>. Tick 'Wrap arrays' to get <tag><item>a</item><item>b</item></tag> instead. Arrays at the top level always use the item name.
Why does XML need a root element?
A well-formed XML document must have exactly one root element. If your JSON is an array or an object with several top-level keys, the converter wraps everything in the root name you choose (default root).
What happens to keys that are not valid XML names?
XML element names cannot start with a digit or contain spaces and most symbols. Such characters are replaced with underscores and names that start with a digit get an underscore prefix, for example "2024 sales" becomes <_2024_sales>. The status bar tells you how many names were changed.
Are special characters escaped?
Yes. &, < and > are escaped in text, and quotes are escaped in attribute values, so the output is always well-formed. Control characters that XML 1.0 does not allow are removed.
Is my data uploaded?
No. The conversion runs entirely in your browser with JavaScript, so your JSON is never sent to a server.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.