JSON to XML
Convert JSON into well-formed XML.
How to use JSON to XML
What this tool does
This tool converts a JSON document into well-formed, indented XML. JSON objects become nested elements, arrays become repeated elements, and primitive values (strings, numbers, booleans, null) become element text content. The result is a complete XML document with an XML declaration and consistent indentation. The conversion happens entirely inside your browser — the JSON you paste is never uploaded anywhere.
Why you might need it
Plenty of systems still speak XML rather than JSON: SOAP web services, RSS and Atom feeds, many enterprise integrations, Android layout and configuration files, and a long tail of legacy APIs. When the data you have is JSON but the system you are feeding expects XML, you need a faithful conversion. Doing it by hand means inventing element names, escaping special characters, and getting the nesting right — tedious and easy to get wrong. This tool produces correct, predictable XML in one click.
How to use it
- Paste your JSON into the input box, or drop a
.jsonfile onto it. - Set the Root element name — XML must have exactly one root, and this wraps the whole document.
- Set the Array item element name — each member of a JSON array is emitted with this tag.
- Choose an indentation width: 2 spaces, 4 spaces, or tab.
- Click Convert to XML, or press Ctrl/Cmd + Enter, then copy the result.
How the mapping works
The conversion follows a simple, consistent set of rules. An object turns into
an element whose children are one element per key. An array turns into a series
of repeated elements — all sharing the array-item name — because XML has no
native list type. A primitive becomes the text inside its element, so
{"private": true} produces <private>true</private>. Empty objects and
arrays, and null values, become self-closing elements like <meta/>. The
whole tree is wrapped in your chosen root element and prefixed with a standard
<?xml version="1.0" encoding="UTF-8"?> declaration.
Common pitfalls
The most common surprise is element naming. JSON keys may contain spaces,
hyphens at the start, leading digits, or symbols — none of which are legal in an
XML element name. When that happens the tool replaces the offending characters
and, if the name had to change, records the original key in a name attribute
so you can still see what it was. The other thing to keep in mind is that XML is
verbose: arrays in particular expand into many repeated tags, so a large JSON
array produces a noticeably larger XML document. Invalid JSON — single quotes,
trailing commas, comments — will be rejected with a clear error before any
conversion is attempted.
Tips and advanced use
If you are generating an RSS or Atom feed, set the root element to rss or
feed and the array-item element to item or entry to match the format you
need. For configuration files, choosing a meaningful root name makes the output
self-documenting. Because every value is escaped, you can safely convert JSON
that contains angle brackets, ampersands, or quotes — they will appear correctly
as <, &, and " in the output. And since the conversion is
fully client-side, JSON containing internal identifiers or credentials can be
converted without any of it leaving your device.
Frequently asked questions
Is my JSON sent to a server?
How are JSON arrays represented in XML?
What happens to the root and array-item element names?
Are special characters escaped?
What if a JSON key is not a valid XML element name?
Related tools
XML to JSON
Convert XML documents into JSON.
XML Formatter
Pretty-print and indent messy XML.
YAML to JSON
Convert YAML into JSON.
JSON to YAML
Convert JSON into readable YAML.
Base64 Encoder & Decoder
Encode and decode Base64, with full UTF-8 support.
URL Encoder & Decoder
Encode and decode URL-safe text.