JSON to XML Converter

Convert JSON into well-formed XML for systems that only accept XML. Keys become elements, arrays become repeated elements, and special characters are escaped for you.

Updated
Runs in your browser. Your data is not uploaded.

Used when the JSON has more than one top-level key.

Converts as you type for inputs up to 200 KB.

How to use the JSON to XML Converter

  1. Paste JSON into JSON input, or upload or drop a .json file.
  2. Set the Root element name used when the JSON has more than one top-level key, and the Indent.
  3. Press Convert, then copy the XML or download converted.xml.

How it works

  • Each object key becomes an element with that name, and its value becomes the element's content.
  • An array repeats the element once per item: "tag": ["a", "b"] → <tag>a</tag><tag>b</tag>.
  • Keys that start with @ become attributes, and a #text key becomes the element's text.
  • null and empty strings become empty elements such as <note/>. Numbers and booleans are written as text.
  • If the JSON is one object with a single key, that key is the root. Otherwise everything is wrapped in the root element you choose, and top-level array items are called item.
  • Keys that aren't valid XML names are fixed: spaces become _, and a name that starts with a digit gets a _ in front. Each change is listed as a warning.

Examples

Input:

{"order": {"@id": "1001", "customer": "Ada & Co", "items": [{"sku": "A1", "qty": 2}, {"sku": "B7", "qty": 1}], "paid": true}}

Output:

<?xml version="1.0" encoding="UTF-8"?>
<order id="1001">
  <customer>Ada &amp; Co</customer>
  <items>
    <sku>A1</sku>
    <qty>2</qty>
  </items>
  <items>
    <sku>B7</sku>
    <qty>1</qty>
  </items>
  <paid>true</paid>
</order>

Limitations

  • Arrays nested directly inside arrays have no key to name their elements, so the inner items are called item.
  • The output has no schema or namespace declarations. Add them yourself if the receiving system needs them.
  • Type information is lost: 2 and "2" both become the text 2.
  • Files are limited to 5 MB.

Frequently asked questions

How do I make an XML attribute from JSON?

Start the key with @. {"book": {"@id": "b1"}} becomes <book id="b1"/>.

Why is my output wrapped in a root element?

An XML document must have exactly one root element. When the JSON has several top-level keys, or is an array, the converter adds the root you named.

Does it add an XML declaration?

Yes, <?xml version="1.0" encoding="UTF-8"?> is added at the top. Untick Add XML declaration to leave it out.

Is my JSON uploaded?

No. The conversion runs in your browser.

Often used together with the JSON to XML Converter.