JSON to XML converter
Convert JSON to well-formed, indented XML. Runs entirely in your browser.
Runs 100% in your browserHow to convert JSON to XML
- Paste your JSON. Paste a JSON object or array into the input.
- Name the root element. Set the tag that wraps the document — it defaults to <root>.
- Copy the XML. Copy or download the generated, indented XML.
Two different data models
JSON and XML look similar but model data differently, and that gap is what a converter has to bridge. JSON has objects, arrays and typed scalars, and its top level can be any of them. XML has exactly one root element, a tree of elements with optional attributes, and text — but no native arrays and no types; everything is ultimately text. The mapping here is the most predictable one: each key becomes an element, a nested object nests, an array repeats its element, and scalars become text content. Still useful in plenty of places — SOAP services, enterprise integrations and XML-only config formats that won't take JSON.
Where the mapping has to make choices
Because the two models don't line up exactly, a few decisions are baked in. Everything is wrapped in a single root element, since XML demands one. Keys that aren't legal XML names are sanitised so the output always parses. Every value becomes an element — the converter doesn't try to guess which fields should be attributes, which keeps the result predictable. And types collapse to text, so a number or boolean survives as its string form. Knowing these rules up front means the output never surprises you.
Well-formed output, and tidying existing XML
Markup characters in your data are escaped so the document stays well-formed. If you already have XML that's minified or messy, the XML formatter re-indents and checks it; and the JSON formatter is the place to confirm your source JSON is valid before converting.
Frequently asked questions
- Each object key becomes an element, a nested object becomes nested elements, and an array becomes the same element repeated once per item. Primitive values (strings, numbers, booleans) become the element's text content. The whole thing is wrapped in a root element you name.
- XML requires exactly one top-level element, but JSON's top level can be an array or even a bare value. Wrapping everything in a single named root is what makes the output well-formed regardless of the JSON's shape.
- XML names can't start with a digit and can't contain spaces or most punctuation. Keys that break those rules are sanitised — invalid characters become underscores, and a name that starts with a non-letter gets an underscore prefix — so the result always parses.
- An array becomes sibling elements that repeat the same tag — the natural XML idiom for a list. But XML has no notion of arrays or number types, so the structure is approximated and every scalar becomes text: converting the result back, a reader can't tell that
1965was a number rather than the string "1965". - Yes —
&,<and>in text content are escaped to their entities, so a value containing markup characters keeps the document well-formed. - Yes — conversion runs in your browser; nothing is uploaded.