Paste JSON or drop a file to get well-formed XML. The awkward parts — JSON keys that are not legal XML names, arrays at the top level, characters that must be escaped — are handled rather than emitted as broken markup.
Keys that are not legal element names
xml in any casing, which the specification reserves.
Keys that break those rules are renamed — spaces and symbols become underscores, a leading digit gains a leading underscore — and you get a note saying how many were changed. Emitting the original names would produce a file that no XML parser will open, which is worse than a renamed element.
Arrays and the single-root rule
root by default), and array members are emitted as repeated elements named item. Both names are configurable, and choosing meaningful ones — orders and order — makes the result far more readable.
An object with exactly one top-level key already has a valid root and is left alone.
Escaping and empty values
&, < and > are escaped in text, and quotes are escaped inside attribute values. Nothing needs doing on your side — pasting text that contains an ampersand is safe.
null becomes an empty element. Empty elements are written self-closing (<name/>) unless you turn that off, in which case they become <name></name>. The two are identical to any conforming parser, but some hand-rolled readers only accept one.
Other names for this
Also searched as “convert json to xml”, “json to xml online”.
Questions
- Why did my key names change?
- They were not legal XML element names. Spaces and punctuation became underscores, and names starting with a digit gained a leading one. The tool reports how many it renamed.
- Can I control the element name used for array items?
- Yes — set “Array item name”. Using the singular of the wrapper (
orders/order) gives the most idiomatic XML. - How are attributes produced?
- A key beginning with
@becomes an attribute rather than a child element, which is the inverse of what our XML to JSON tool produces — so a round trip preserves them. - Is my data uploaded anywhere?
- No. The conversion runs as JavaScript inside this tab. Open your browser's Network panel and convert something — you will see no request carrying your data, because there is no server to send it to. You can also turn your Wi-Fi off and convert anyway.