Back to Tools

JSON to XML

Convert structured JSON data into standard XML format

Source JSON

Bridge JSON and XML

Modern APIs speak JSON, but plenty of enterprise systems, SOAP-style services and configuration formats still want XML. This converter reads a JSON document and writes the equivalent tree of tags. It starts the output with an XML declaration and runs entirely in your browser once the page has loaded.

Converting in three moves

  1. Paste JSON into the Source JSON box, or press Sample to load an example with a user object and a list of items.
  2. Press Convert to XML. If the JSON is malformed, an Invalid JSON dialog explains the parser error.
  3. Look over the dark XML Output panel and press Copy XML.

Mapping rules the tool follows

  • Every JSON key becomes a tag with the same name, and its value is placed between the opening and closing tags.
  • Nested objects become nested tags.
  • Array entries are each wrapped in an item tag inside the parent element for the array.
  • If your JSON has exactly one top-level key whose value is an object or array, that key becomes the root element. Otherwise the whole document is wrapped in a root tag named root.
  • Numbers, booleans and text are written as element content; null appears as the word null.

So {"user":{"name":"John"}} yields a user root containing a name tag, while a top-level object with several keys is placed inside root.

Who uses this

  • Developers feeding a JSON payload into a legacy service that only accepts XML.
  • Testers who want quick XML samples that correspond to an existing JSON fixture.
  • Analysts moving a small reference dataset between two tools with different import formats.

Points to check afterward

The output is a single continuous line with no indentation, so run it through a formatter if people will read it. Values are inserted as-is, without escaping, so text containing an ampersand or angle bracket will produce invalid XML and should be cleaned first. Keys are used verbatim as tag names, which means keys with spaces, or starting with a number, will not be valid tags. JSON has no attributes, so everything is written as elements. A top-level array is best wrapped in an object with a named key, for example {"orders":[...]}, so you get a meaningful root and item tags.

Related Articles

Related Tools







Frequently Asked Questions

What tag is used for array elements?
Each entry in a JSON array is written as an item element inside the tag that holds the array. For example, a list stored under items produces an items tag containing several item tags, one per entry.
How does the tool choose the root element?
When the JSON has a single top-level key with an object or array value, that key is used as the root. In every other case the tool wraps the entire document in a root element literally called root.
Is the XML pretty-printed?
No. The result appears as one unbroken line after the XML declaration. It is valid to parse as long as the content is well-formed, but you may want to run it through an XML formatter before handing it to people.
Why does my output break when text contains ampersands or angle brackets?
Values are written into the document without escaping, so characters such as ampersand and less-than remain raw and make the XML invalid. Replace them with entities like & and < in your JSON strings before converting.
Can I convert a top-level JSON array?
It is safer to wrap it in an object first, such as an orders key holding the array. A bare array can produce numeric tag names, which are not valid XML, whereas a wrapped array gives you a named root and item tags.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.