Skip to content
DoItJag

JSON to XML Converter

Turn JSON into XML for systems that only accept XML. The result is always well-formed, with special characters escaped.

or drop a file here · .json, .txt · up to 20 MB

Options

About the JSON to XML Converter

Some systems accept only XML: older SOAP services, some bank uploads, enterprise middleware. This converter turns JSON into well-formed XML with every special character escaped.

How JSON is turned into XML

  • An object with exactly one key uses that key as the root element. Anything else is wrapped in a root element whose name you choose (“root” by default).
  • Each key becomes a child element, and its value becomes the content.
  • A key starting with @ becomes an attribute of its parent, and “#text” becomes the parent’s own text.
  • An array repeats its key once per item. A top-level array, or an array inside an array, uses the list item name (“item” by default).
  • null and empty strings become empty elements written as a single self-closing tag.

Worked example

Select Try an example and Convert to XML. The sample JSON has one top-level key, “catalog”, so that is the root. Its “book” array produces two book elements. The “@id” key of each becomes an id attribute, while “title” and “price” become child elements. The “tags” array inside the first book produces two tags elements, one per value.

Untick Add XML declaration if the output is going to be pasted inside another document rather than saved as a file.

Names that XML does not allow

JSON keys can be anything, but XML names cannot contain spaces, cannot start with a digit and cannot use most punctuation. The converter replaces each forbidden character with an underscore and puts an underscore in front of a leading digit, so “first name” becomes first_name and “2024” becomes _2024. A warning lists every renamed key.

Good to know

  • Large numbers such as 20-digit IDs are written exactly, not rounded.
  • The JSON must be valid. If you need help finding an error, try the JSON validator.
  • The opposite direction is XML to JSON.

How to use JSON to XML Converter

  1. Paste JSON or open a .json file.
  2. Choose the indentation, root and list item names, and whether to add an XML declaration.
  3. Select Convert to XML, check the result, then copy or download it.

Privacy: how it works

Everything happens in your browser. Your text is not sent to any server.

Frequently asked questions

How do I make an XML attribute?

Start the key with @. For example {"book": {"@id": "b1", "title": "Godan"}} becomes <book id="b1"><title>Godan</title></book>. Use "#text" for text next to attributes.

What happens to keys that are not valid XML names?

Characters that XML does not allow are replaced with underscores, and names that start with a digit get an underscore in front. The page lists every key it renamed.

Where does the root element come from?

If the JSON is an object with exactly one key, that key is the root. Otherwise everything is wrapped in the root name you choose, "root" by default.