How to convert JSON to XML
- Paste your JSON into JSON. Start a key with @ to make it an attribute.
- Set Root element to the name your XML should be wrapped in. It's only used when the JSON doesn't already have a single top-level key.
- Copy the XML or download it as a .xml file.
Conversion rules
| JSON | XML |
|---|---|
{"order": {...}} |
<order>...</order> as the root |
"name": "Ada" |
<name>Ada</name> |
"@id": "A-1042" |
id="A-1042" on the parent element |
"item": [{...}, {...}] |
Two <item> elements |
"note": null |
<note/> |
{"a": 1, "b": 2} |
Wrapped in <root> |
The output starts with <?xml version="1.0" encoding="UTF-8"?> and is indented with 2 spaces. Paste it into the XML formatter if you need 4.
Keys that can’t be element names
JSON keys can be any string, but XML element names can’t contain spaces, can’t start with a digit and can’t start with most punctuation. The converter fixes those for you and says so in the status line: “first name” becomes first_name and “2fa” becomes _2fa. If you need a different name, such as firstName or twoFactor, rename the key in the JSON first.
Lists inside lists
XML has no way to write a list directly inside another list, so each inner list is wrapped in an <item> element. Characters that XML 1.0 cannot hold at all, such as most control characters, are dropped from the text.