JSON to XML Converter
Convert JSON to XML and XML back to JSON. Values are properly escaped, arrays are handled correctly, and invalid element names are sanitised — so the output is always well-formed XML.
XML requires a single root element; JSON has no equivalent.
XML output
JSON output
How the two formats map to each other
JSON and XML do not line up perfectly, so a few rules decide the conversion:
- Root element. XML needs exactly one root; JSON does not have one, so you supply the name.
- Objects become nested elements.
- Arrays become repeated elements using the property name.
- Strings are escaped —
&,<,>,"and'— so the result is well-formed XML. - Null becomes an empty element marked
nil="true".
Worked example. This JSON:
{ "note": "a & b < c", "tags": ["x", "y"] }
becomes this XML:
<root>
<note>a & b < c</note>
<tags>x</tags>
<tags>y</tags>
</root>
Common pitfalls this tool avoids
| Pitfall | Broken output | Correct output |
|---|---|---|
Unescaped & |
<note>a & b</note> |
<note>a & b</note> |
| Array of plain values | <tags><0>x</0></tags> |
<tags>x</tags> |
| Key starts with a digit | <2fa>true</2fa> |
<_2fa>true</_2fa> |
| Null value | <note></note> |
<note nil="true"/> |
Frequently asked questions
- Are special characters escaped in the XML output?
- Yes. Ampersand, less-than, greater-than, quotes and apostrophes are converted to XML entities, so values such as "a & b < c" produce well-formed XML.
- How are JSON arrays represented in XML?
- Each array item is emitted as a repeated element using the property name. An array of objects nests inside each repeated element, while an array of plain values becomes one element per value.
- What happens to invalid XML element names?
- XML element names must start with a letter or underscore and cannot contain spaces. Names that break these rules, such as keys starting with a digit, are sanitised automatically.
- Is my data uploaded anywhere?
- No. Both conversions run entirely in your browser. Nothing you paste is sent to a server.
Related tools
Text ↔ Binary
Convert text to binary using real UTF-8.
Decimal → Octal
Base-10 to base-8 number conversion.
Epoch → Date
Turn a Unix timestamp into a readable date.
RGB ↔ HEX
Two-way color conversion with live preview.
UTC → EST
US Eastern time with automatic daylight saving.
BPM → Milliseconds
Note lengths in ms for delay timing.
Last updated: August 31, 2026