AnyFormat

00 JSON → XML

JSON to XML

Legal element names guaranteed, entities escaped, one real root.

01JSON in
02XML out
03Options 5

XML allows exactly one top-level element, so arrays need a wrapper.

  • No upload The conversion runs in this tab. Your file never travels — not to us, and not to the advertising.
  • No sign-up, no email, no daily cap There is no account system to sign up to.
  • No size limit we invented Only your device's memory — about ~2 GB on a desktop browser, ~400 MB on a phone.
  • Turn your Wi-Fi off and convert anyway The conversion needs nothing but this page. Ads will not load without a connection; your file will still convert. That is the whole claim, and it takes five seconds to check.

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

JSON keys can be anything. XML element names cannot: they may not contain spaces or most punctuation, may not begin with a digit, and may not begin with the letters 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

An XML document must have exactly one root element. A JSON array has none, and a JSON object with several top-level keys has too many. Both are wrapped in a root element (named 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.