JSON to XML Converter
JSON to XML in the browser: @attribute / #text convention, arrays as repeated elements, named root and item elements, declaration — the reverse of XML to JSON.
Indented XML with attributes, text and repeated elements as mapped, the element and attribute counts, and the keys that had to be renamed to be valid XML names.
Example: {"order":{"@id":"7","items":{"item":[{"@sku":"A1","qty":2}]},"note":null}} → <order id="7"><items><item sku="A1"><qty>2</qty></item></items><note/></order>; [1,2,3] → <root><item>1</item>…
The XML → JSON mapping,
run backwards.
How keys become elements, attributes and text, what happens at the top level, and what XML cannot carry.
The mapping
Keys become child elements in the order they appear. A key starting with the attribute prefix (@ by default) with a scalar value becomes an attribute; the text key (#text) becomes the element's text content; an array repeats the element once per item; null becomes an empty element, or one marked xsi:nil="true" with the namespace declared on the root. Numbers and booleans are written as their text, and &, < and > (and " in attributes) are escaped.
Top level and names
An object with a single key becomes that element; anything else — several keys, an array, a scalar — is wrapped in the root element you name, an array using the item element name for each entry. Keys that are not valid XML names (starting with a digit, containing spaces or symbols, starting with "xml") are sanitised with underscores and listed, so nothing is silently dropped.
What is lost
XML has no types (2 and "2" both become 2), no way to say "empty array", and elements from one object always come out grouped by key — the round trip through XML → JSON and back reproduces the document only when the JSON already follows this convention. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.
SOURCES
- Mapping mirrors the XML → JSON page: "@name" → attribute, "#text" → text, array → repeated element, null → empty element (or xsi:nil="true"); names sanitised to the XML Name production
Last reviewed 22 September 2026. How results are checked: How we verify.