JSON to XML Converter
Paste JSON or open a file to get well-formed XML. The conversion runs entirely in your browser, so your data is never uploaded.
Swap to XML to JSONPaste text, or drop a file here
Example
JSON input
[
{ "id": 1, "name": "Ada", "address": { "city": "London" }, "tags": ["math", "code"] },
{ "id": 2, "name": "Grace", "address": { "city": "New York" }, "active": true }
]XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item>
<id>1</id>
<name>Ada</name>
<address>
<city>London</city>
</address>
<tags>math</tags>
<tags>code</tags>
</item>
<item>
<id>2</id>
<name>Grace</name>
<address>
<city>New York</city>
</address>
<active>true</active>
</item>
</root>How it handles tricky cases
The single root rule
XML allows only one top-level element. If the JSON is an object with one key, that key is the root. Otherwise the output is wrapped in the root element you choose.
Arrays
A key holding an array becomes one repeated element per value. A top-level array uses the array item name for each entry.
Attributes
Keys starting with @ become attributes and #text becomes element text, matching what the XML to JSON page produces.
Invalid element names
XML names can't contain spaces or start with a digit, so such keys are adjusted: "1 bad" becomes _1_bad. A note reports how many keys changed.
Null values
A null becomes an empty element.
Do it from code
Python with xmltodict:
import json, xmltodict
with open("in.json", encoding="utf-8") as f:
data = json.load(f)
print(xmltodict.unparse({"root": data}, pretty=True))
Questions
Are special characters escaped?
Yes. Characters like & and < are written as entities, so the output stays well-formed.
Can I convert the XML back?
Yes, with the XML to JSON page. Numbers become text in XML, so use its detection option to restore them.
Is my JSON uploaded?
No. It is converted on your device.