ToolJutsu
All tools
Developer Tools

JSON to XML

Convert JSON into well-formed XML.

0 chars
Tip: press Ctrl/ + Enter
Processed on your device. We never see your files.

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

  1. Paste your JSON into the input box, or drop a .json file onto it.
  2. Set the Root element name — XML must have exactly one root, and this wraps the whole document.
  3. Set the Array item element name — each member of a JSON array is emitted with this tag.
  4. Choose an indentation width: 2 spaces, 4 spaces, or tab.
  5. 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 &lt;, &amp;, and &quot; 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?
No. The conversion runs entirely in your browser with JavaScript. Nothing you paste or drop is uploaded, so it is safe to convert payloads that contain tokens or private data. You can confirm this in your browser's Network tab.
How are JSON arrays represented in XML?
XML has no array type, so each element of an array is emitted as a repeated child element. By default that element is named item, but you can change the array-item element name in the options.
What happens to the root and array-item element names?
XML requires a single root element, so the whole document is wrapped in one — named root by default. Array members are wrapped in the array-item element. Both names are configurable, and invalid characters in them are sanitised automatically.
Are special characters escaped?
Yes. The characters &, <, and > are escaped in text content, and quotes and apostrophes are additionally escaped inside attribute values, so the output is always well-formed XML.
What if a JSON key is not a valid XML element name?
XML element names are stricter than JSON keys — they cannot contain spaces or start with a digit, for example. Such keys are sanitised into a valid name, and the original key is preserved in a name attribute so no information is lost.

Related tools