How to convert JSON to XML
- Paste your JSON into the left panel, upload a
.jsonfile, or load it from a URL. - The XML appears on the right as you type. Pick a Root element name (
<root>,<data>,<document>, or<response>) to match what the receiving system expects. - If the top level of your JSON is an array, choose the Array item name (
<item>,<element>,<row>, or<entry>) used for each entry. - Click Copy or Download .xml.
If the input is not valid JSON, the error bar shows the line and column. Click Fix to repair trailing commas, single quotes, or comments before converting.
What the output looks like
Input:
{
"orderId": 1042,
"customer": { "name": "Maya & Co", "vip": true },
"items": [
{ "sku": "A-100", "qty": 2 },
{ "sku": "B-220", "qty": 1 }
],
"ship date": "2026-06-23",
"notes": null
}
Output:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<orderId>1042</orderId>
<customer>
<name>Maya & Co</name>
<vip>true</vip>
</customer>
<items>
<sku>A-100</sku>
<qty>2</qty>
</items>
<items>
<sku>B-220</sku>
<qty>1</qty>
</items>
<ship_date>2026-06-23</ship_date>
<notes xsi:nil="true"/>
</root>
Four rules explain everything above:
- Arrays become repeated elements named after their key, so
itemsappears once per entry with no wrapper. A root-level array uses the Array item name instead. nullbecomesxsi:nil="true", and thexsinamespace is declared on the root only when a null is present.- Keys are sanitised into valid XML names: spaces and other illegal characters become
_, a key starting with a digit gets a leading_, and names beginning withxmlare prefixed as well. - Text is entity-escaped:
&,<,>and"replace the literal characters so the output is always well-formed.
Limits and notes
- Files up to 5 MB. Conversion runs as JavaScript in your browser; nothing is uploaded.
- There is no schema, so the tool cannot know whether a value should be an attribute or a child element. Everything becomes an element.
- Numbers and booleans are written as plain text, since XML has no types of its own. Converting back with XML to JSON restores them only when type detection is on.
- Key order is preserved. Empty objects become self-closing tags such as
<meta/>. - Arrays of arrays have no natural XML shape: the inner arrays are flattened into repeated elements with the same name. Restructure first if that nesting matters.
- Still choosing a format? Read JSON vs XML, and see JSON key naming conventions for keys that convert cleanly.