jsonecho

JSON to XML

Paste JSON and get clean, indented XML. Pick the root element name and keep or drop the XML declaration.

Loading the tool...

How to use JSON to XML

  1. Paste your JSON or upload a file.
  2. Set the root element name if you need something other than root.
  3. Copy the XML or download it as a .xml file.

About JSON to XML

JSON and XML describe data in different ways, so a conversion has to make a few decisions. Here is what this tool does: every JSON key becomes an element, arrays become repeated elements with the same name, and keys that begin with @_ become attributes. A key called #text holds the text content of an element that also has attributes.

If your JSON has a single top-level key, that key becomes the root element. Otherwise everything is wrapped in the root name you choose, root by default. Keys that are not valid XML names, for example ones that start with a digit or contain spaces, are cleaned up so the output is always well formed.

Frequently asked questions

How are JSON arrays written in XML?

As repeated elements. {"tag":["a","b"]} becomes <tag>a</tag><tag>b</tag>. XML has no real array type, so this is the usual convention.

How do I create XML attributes?

Prefix the key with @_, for example {"item":{"@_id":"7","#text":"Keyboard"}} gives <item id="7">Keyboard</item>.

What happens to null values?

They become empty elements, for example <notes/>. XML has no null, so an empty element is the closest equivalent.

Why was my key renamed?

XML names cannot start with a digit or contain spaces and most punctuation. Characters that are not allowed are replaced by underscores, and names starting with a digit get an underscore in front.

Does the converter escape special characters?

Yes. Ampersands, angle brackets and quotes inside values are escaped automatically.

More in Converters

All tools →