Convert JSON to XML in your browser
Legacy APIs, SOAP payloads and many config formats still expect XML, but modern data is usually JSON. This converter turns any valid JSON object or array into well-formed XML with consistent two-space indentation, so the result is always valid and ready to use.
How it works
The converter walks the JSON and maps each construct to XML:
- Objects become nested elements, one per key.
- Arrays repeat their parent element once per item — the standard lossless
convention — so
"tags": ["a","b"]becomes<tags>a</tags><tags>b</tags>. - A single
<root>element wraps the whole document so it is always well-formed. - Escaping: the
&,<and>characters in text are escaped, and property names that aren’t legal XML element names are sanitised. - Null has no XML equivalent, so it is emitted as an empty element.
Example
This JSON:
{ "name": "demo", "tags": ["a", "b"] }
becomes:
<root>
<name>demo</name>
<tags>a</tags>
<tags>b</tags>
</root>
The tags array repeated the <tags> element once per item, and <root> wraps
the document. The conversion happens entirely in your browser — your data is
never uploaded or stored.