JSON to XML Converter

Convert JSON into XML in your browser. Each key becomes an element; arrays become repeated tags. Works best when your JSON has a single top-level key.

Document Tools Free No upload Instant

Loading JSON to XML Converter…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste JSON and get XML. Every key becomes an element name, nested objects become nested elements, and an array becomes the same tag repeated once per item. A UTF-8 declaration is added, values are escaped, and it runs in your browser. One thing to plan for: the tool does not add a wrapper root, so a single top-level key keeps the result well-formed.

What the JSON to XML Converter Does

This turns a JSON value into XML. The tool walks the parsed structure and writes an element for each key: a nested object becomes nested elements, an array repeats its key once per item, and a plain value becomes an element holding that text.

It prepends a UTF-8 XML declaration and escapes the reserved characters in values. It does not wrap everything in an extra root element, so whether the result is well-formed depends on your JSON having a single top-level key.

How It Works

Paste or type JSON. It is parsed first, so invalid JSON shows an error rather than producing broken XML.

Each key becomes an element name. Objects nest, arrays repeat the key for each item, and primitive values are written as the element's text, escaped for the ampersand, less-than and greater-than characters.

A UTF-8 declaration is added at the top. Copy the XML or download it as a .xml file — all in your browser.

Data source & conversion logic

  1. Parse the JSON. The input is parsed first, so malformed JSON is caught before any XML is built.
  2. Walk each key. Every key becomes an element name at its level of nesting.
  3. Expand objects and arrays. Nested objects nest; an array repeats the same tag once per item; values are escaped.
  4. Add the declaration. A UTF-8 XML prolog is prepended, ready to copy or download.

How JSON maps to XML

Key with a value = <key>value</key> (value escaped) Key with an object = <key> nested elements </key> Key with an array = <key> repeated once per item No extra root is added — your top-level key is the root
Worked example
The JSON {"book": {"title": "X", "year": 2024}} becomes <book> containing <title>X</title> and <year>2024</year> — one top-level key, so one valid root.

Two or more top-level keys would produce two or more root elements, which XML does not allow. Wrap them under a single key first.

Privacy

Your JSON is parsed and converted entirely in your browser — there is no server and nothing is uploaded.

The data never leaves your device, so even sensitive records stay private.

No account, no stored copy; the conversion is gone when you close the tab.

Technical Details

InputJSON
OutputXML (.xml)
KeysBecome element names
ArraysRepeat the same tag
Root wrapperNone added
EscapingAmpersand, less-than, greater-than
Processing100% in-browser

Standards & references

  • XML 1.0 (well-formed) — A well-formed document needs exactly one root element; supply a single top-level JSON key to satisfy this.
  • XML element naming — Element names cannot contain spaces or start with a digit; JSON keys are used as-is, so a non-name key produces invalid XML.
  • Predefined entities — Values are escaped for the ampersand, less-than and greater-than characters.

Accuracy & Limitations

No wrapper root is added. XML requires exactly one root element, so JSON with a single top-level key converts cleanly, but an object with two or more top-level keys produces two or more roots — which is not well-formed. Nest them under one key first.

Keys are used as element names without sanitisation. A key with a space, a leading digit, or a character XML forbids in a name (such as the at-sign or a slash) produces invalid XML. Rename such keys before converting.

Everything becomes an element — there are no attributes. An array becomes the same tag repeated once per item, which is the usual XML pattern for a list.

Values are written as text and escaped for the ampersand, less-than and greater-than characters. Numbers and booleans become their text form, since XML carries no separate types here.

Invalid JSON is reported as an error, so you will not get half-built XML from a typo.

Real-World Use Cases

Target an XML API

Convert a JSON object into the XML body an older service expects.

Generate config

Turn a JSON config into an XML equivalent for a tool that needs XML.

Round-trip test

Produce XML from JSON to exercise an XML import path.

Learn the mapping

See how objects and arrays translate into nested and repeated elements.

When to use it — and when not to

Good for

  • JSON with a single top-level key (one clean root)
  • Element-based XML without attributes
  • Lists that should become repeated tags

Not the best choice for

  • JSON with several top-level keys (multiple roots)
  • Keys that are not valid XML element names
  • XML that needs attributes or namespaces

If you need attributes, namespaces or a guaranteed root, wrap your data under one key first or use a configurable converter. To go the other way, use the XML to JSON converter.

Frequently Asked Questions

Why isn't my XML well-formed?
The most common reason is several top-level keys, which produce several root elements. XML allows only one root, so wrap your keys under a single top-level key first.
Does it add a root element?
No. Your top-level key becomes the root, so give the JSON a single top-level key for a clean, well-formed document.
What happens to a key with a space?
It produces an invalid element name, because XML names cannot contain spaces. Rename the key (for example full name to full_name) before converting.
Can a key start with a number?
No. XML element names cannot start with a digit, so a key like 2024 yields invalid XML. Rename it first.
How are arrays handled?
An array repeats its key once per item — the standard XML pattern for a list. Three items under a tags key become three tags elements.
Does it create attributes?
No. Every key becomes a child element; nothing is written as an attribute.
Are numbers kept as numbers?
Values become element text. XML here has no separate types, so a number or boolean appears as its text form inside the element.
Does it escape special characters?
Yes. The ampersand, less-than and greater-than characters in values are escaped to their XML entities.
What if my JSON is invalid?
You get a clear error message instead of half-built XML, because the JSON is parsed before any conversion.
Is there an XML declaration?
Yes. A UTF-8 XML prolog is added at the top of the output.
Is my data uploaded?
No. The conversion runs entirely in your browser, so your data never leaves your device.
How do I convert XML back to JSON?
Use the XML to JSON converter. Remember it drops attributes, so an exact round-trip is only guaranteed for attribute-free, element-based XML.

References

Walks your parsed JSON into XML: every key becomes an element name, nested objects nest, and arrays repeat the same tag. Values are escaped for the ampersand, less-than and greater-than characters. It adds a UTF-8 declaration but no wrapper root, so give it a single top-level key for valid XML. Runs in your browser.

Popular

CSV to JSON Converter

CSV to JSON Converter online: fast, private and free for everyday document work.

DocumentOpen Tool
Popular

JSON to CSV Converter

Convert with JSON to CSV Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool
Trending

Markdown to HTML

Markdown to HTML in seconds — accurate, free and processed locally in your browser.

DocumentOpen Tool

CSV to Excel Converter

Convert with CSV to Excel Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool

Excel to CSV Converter

Excel to CSV Converter online: fast, private and free for everyday document work.

DocumentOpen Tool

Excel to JSON Converter

Convert with Excel to JSON Converter, preserving structure and data, with zero uploads.

DocumentOpen Tool

Ready to try the JSON to XML Converter?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.