JSON to XML
Processed Client SideConvert a JSON structure into equivalent, properly indented XML markup with a configurable root element.
Bookmark this tool now — skip the search next time you need it.
About JSON to XML
This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.
The JSON to XML converter turns a JSON document into equivalent, properly indented XML markup — useful when a SOAP endpoint, a legacy integration, an RSS-style feed, or an enterprise system expects XML and everything upstream of it speaks JSON. Object keys become element names, nested objects become nested elements, and each item in an array repeats its parent element rather than inventing a wrapper. You control the indentation, whether the XML declaration is emitted, and the root element name used when the document has no single natural root. Keys that would be illegal as XML element names are sanitised automatically, and everything runs in your browser.
Key features
- Objects, arrays, and primitives converted in one pass, with nesting preserved
- Arrays repeat their element once per item — the shape most XML consumers expect
- Automatic root handling: a document with one top-level key uses it as the root, anything else is wrapped in a root element you name
- Optional <?xml version="1.0" encoding="UTF-8"?> declaration
- Indentation as 2 spaces, 4 spaces, or tabs
- Key names sanitised into valid XML element names — illegal characters become underscores, and a leading digit gets an underscore prefix
- Ampersands and angle brackets escaped as &, <, and > so the output is well-formed
- Empty objects, empty arrays, and null values emitted as self-closing tags
- Syntax highlighting on the JSON input and the XML output, with parse errors reported on the failing line
How to use it
- Paste your JSON into the input pane, or edit the sample that is already there.
- Set the indentation, type the root element name, and decide whether you want the XML declaration.
- Press Convert.
- Read the XML in the output pane and copy it.
Tips & common mistakes
- The conversion is one-way by design. XML has attributes, namespaces, and mixed content that JSON has no equivalent for, so converting back will not reproduce your original document exactly.
- Type information is lost: 42, "42", and true all become element text. A consumer that needs types has to get them from an XSD or from its own expectations rather than from the markup.
- A single-item array and a plain value produce identical XML, because both emit one element. If the consumer must tell them apart, that distinction has to live in the schema.
- Give the root a meaningful name when your JSON has several top-level keys. The default "root" is valid but says nothing, and many XML consumers key off the document element.
- Keys with spaces, slashes, or colons are rewritten with underscores, since XML element names cannot contain them. Check the output if your keys are unusual — the sanitised name is what the consumer will see.
- Turn the declaration off when the XML is being embedded inside a larger document; a declaration is only legal at the very start of a file.
- Attributes are never generated — every value becomes element text. If the target system requires attributes, this output is a starting point to transform, not a finished document.
- To inspect the generated XML with a collapsible tree before using it, open it in the XML Viewer & Formatter.