Developer tool / 02
JSON to XML Converter
Convert JSON into well-formed XML, with control over the root element and indentation.
JSON to XML Converter: TOEA writes each key as an element, turns keys prefixed with @ back into attributes, repeats an element for every array entry, and escapes text so the result parses. Runs 100% locally in your browser with zero server file uploads.
- Category
- Developer tools
- Runs
- In your browser
- Cost
- Free · no sign-up
- Availability
- Ready to use
Runs entirely in your browser
Up to 5 MB · nothing is uploaded
Shaping the JSON first
An XML document needs exactly one root element. A top-level array is placed inside the root named in the Root element field, with one <item> per entry; an object with a single key holding an array gets the same wrapper, with the key repeated as the element name. For better names, wrap the data first: {"orders": {"order": [ … ]}} gives one <orders> element with an <order> for each entry. Arrays nested directly inside arrays lose their inner grouping, since XML can only repeat an element.
null and an empty string both become an empty element such as <note />, so the XML cannot tell them apart.
Namespaces and target schemas
A key containing a colon, such as atom:link, stays a prefixed name, and XML tools reject it unless the prefix is declared. Add the declaration as an attribute on the root object: "@xmlns:atom": "http://www.w3.org/2005/Atom".
When the XML must satisfy a published format, such as a sitemap or a SOAP body, element order and names matter. Build the JSON with keys in the order the format requires, then check the result with XML to JSON or the XML formatter.
How to use it
- Paste JSON or choose a file.
- Set the root element name if needed.
- Copy or download the XML.
Privacy & limitations
The text is converted in your browser and never uploaded, which matters when the file is a config or an export you would rather not hand to a stranger. Keys that XML cannot use as element names are made safe rather than silently dropped.
Related tools
Frequently asked questions
Where does the root element come from?
An object with exactly one top-level key uses that key as the root, unless its value is an array. Anything else needs a name, which is what the root field supplies; a top-level array goes inside that root, with one item element per entry.
How are arrays handled?
The element is repeated once per entry. XML has no array type, so a wrapper element with numeric children would be misleading.
What happens to keys XML cannot use?
Names cannot begin with a digit or contain spaces, so a leading digit gains an underscore prefix and spaces become underscores.
Will it round-trip?
XML converted to JSON and back keeps its elements, attributes, and text. Comments and the original formatting are not preserved.
Free tool · runs in your browser · no account required