Convert JSON to XML
Paste JSON below and get well-formed XML with 2-space indentation. Each object key becomes an element, arrays become repeated elements with the same tag, and `null` becomes an empty element with `null="true"`. Everything runs locally in your browser.
Unlike server-side converters, this runs entirely in your browser — your JSON never leaves the page, so it is safe for config, tokens, or private payloads.
How to convert JSON to XML
- Paste your JSON. Drop a JSON object or array into the box. It is validated first, so malformed JSON gives a clear error instead of broken XML.
- Click Convert to XML. The converter walks the JSON tree: keys become element names, arrays repeat the element, nested objects nest, and null becomes an empty element.
- Copy the XML. Copy the indented, well-formed XML with the button. It starts with an XML declaration and uses a <root> wrapper.
How keys map to elements
Each key in a JSON object becomes an XML element with the same name (invalid characters are replaced with _). So "name": "Ada" becomes <name>Ada</name>. Special characters in values are escaped (&, <, >).
Arrays and nulls
A JSON array becomes repeated elements sharing the parent's tag name — "roles": ["admin","dev"] becomes two <roles> elements. A null value becomes an empty element marked null="true" so the distinction from an empty string survives the round trip.
Nested objects
Nested objects nest as child elements, indented two spaces per level. The whole document is wrapped in a single <root> element because XML requires exactly one root.
FAQ
Does it handle a top-level JSON array?
Yes. A top-level array is wrapped in <root> and each element is emitted as an <item> element, since XML needs a single root and array elements have no natural name.
Are attributes generated?
No — every JSON key becomes a child element, not an attribute. This keeps the mapping predictable and reversible. The exception is null, which is marked with a null="true" attribute.
What happens to characters that are illegal in XML tag names?
Characters outside letters, digits, underscore, dot and hyphen are replaced with an underscore, and names starting with a digit get an underscore prefix, so the output is always well-formed.
Is my data uploaded anywhere?
No. The conversion is pure JavaScript running in your browser; nothing is sent to a server.