JSON to XML
Convert JSON to well-formed, verified XML โ attributes and all.
About this converter
Emits indented XML with correct entity escaping, @-prefixed keys becoming attributes, arrays repeating their element, and a verification step most tools skip: the output is re-parsed through a real XML parser before display, so "well-formed" is checked, not assumed.
What careful emission actually involves
Hand-built XML fails in reliable ways, and this emitter exists to make each one impossible. Escaping: &, < and quotes inside values become entities (the unescaped ampersand is the classic generator bug โ one "Books & Records" and the document dies). Names: JSON happily uses "first name" or "2024" as keys; XML forbids both as element names, so invalid names are sanitised rather than emitted broken. Structure: JSON's anonymous arrays have no XML equivalent, so arrays repeat their parent's element name โ the convention the reverse tool reads back. Nulls become self-closing tags. And because a converter claiming "well-formed" should prove it, the result round-trips through the browser's parser before you see it. Where the output goes: SOAP and enterprise endpoints, RSS assembly, Android resources, config for the Java-shaped corners of the world. The XML declaration is included because half those consumers demand it. The XML formatter handles further pretty-printing or minification downstream.
Frequently asked questions
How do I control attributes vs elements?
Prefix a key with @ for an attribute ({"@id": 1} โ id="1"); everything else becomes a child element. #text sets an element's text beside its attributes โ the same conventions the XML-to-JSON tool emits.
What happens to arrays?
They repeat the element: {"book": [a, b]} emits two <book> elements. XML has no anonymous list syntax, so repetition IS the XML idiom for arrays.
What about JSON keys that aren't valid XML names?
Sanitised to a valid name rather than emitted broken โ XML element names can't start with digits or contain spaces. The alternative (invalid markup) helps nobody.
Is the output guaranteed well-formed?
It's re-parsed by the browser's XML engine before display โ if that check ever failed you'd see a warning, not silently broken markup. Escaping bugs are the whole reason the check exists.