JSON to XML converter
Convert JSON to XML: objects become nested elements, arrays repeat their parent tag, and text is escaped. Key names that are not valid XML names are sanitised.
Conversion happens in this browser tab. Nothing is uploaded, logged, or stored.
The mapping
There is no single official way to represent JSON as XML, because the two models do not line up. XML has attributes and ordered mixed content; JSON has neither. This converter uses the most common and most predictable convention:
- The document gets a single
<root>element, because XML requires exactly one root and JSON does not have one. - Each object key becomes an element with that name.
- Arrays repeat the parent element once per item, rather than inventing a wrapper.
- Scalars become element text, with
&,<and>escaped. nullbecomes a self-closing element.- Nothing becomes an XML attribute. Attributes would be ambiguous on the way back.
Key names that are not valid element names
XML element names are restricted in ways JSON keys are not. A name must start with a letter or underscore and may not contain spaces, slashes, or most punctuation. Keys that break those rules are sanitised: invalid characters become underscores, and a leading digit gets an underscore prefix.
| JSON key | XML element |
|---|---|
"first name" | <first_name> |
"2026" | <_2026> |
"user-id" | <user-id> — hyphens are legal |
"price($)" | <price___> |
Sanitising is lossy: two different keys can collapse to the same element name. If your keys contain punctuation, rename them before converting rather than after.
Round-tripping
Converting JSON to XML and back does not always return the original. Type information
is the main casualty — XML text has no types, so the number 3 and the
string "3" are written identically and come back as whichever the reverse
converter guesses. An array of one element also becomes indistinguishable from a single
value, because both are one repeated element.
If you need a faithful round trip, keep JSON as the source of truth and generate the XML as an output artifact. The reverse tool, XML to JSON, documents what it cannot recover.
Your document stays local
XML is where the payments and procurement world still lives: invoices, purchase orders, SOAP envelopes, supplier records. Documents that carry counterparty names, bank details, and prices you are contractually obliged to keep confidential.
Converting one here does not disclose it. The transformation happens in your browser, with no upload and no server-side processing of your content at any point.