JSONConverter
โ† Back to the tools
๐Ÿ“ฆ

JSON to XML: Build Well-Formed XML from JSON

JSON and XML are both tree formats, which makes the conversion mostly mechanical: an object key becomes an element name, a scalar becomes element text, and an array repeats the element. The converter produces well-formed, validated XML from any JSON document.

Objects become elements

{"person":{"name":"Alice"}} becomes <person><name>Alice</name></person>. Every nested object adds a level of nesting.

Arrays repeat the element

An array value repeats the tag once per item: {"item":[1,2,3]} becomes three <item> elements. This is the XML way of representing a list.

Attributes use the @_ convention

A key such as @_id is written as an XML attribute (<a id="9">โ€ฆ</a>) and #text sets the element text. Parsing XML back to JSON yields the same convention, so both directions are predictable.

Values are escaped automatically

Text containing <, >, & or quotes is escaped to entities, and element names are sanitised so the output is always well-formed โ€” never a half-escaped document.

Null and empty become self-closing tags

{"e":null} becomes <e/>. Use the round-trip check to see the one unavoidable drift: XML has no null, so it comes back as an empty string.

Convert your data free