XML to JSON Converter

How it works
Indent
Valid XML

Input XML

No problems found. This is valid XML.

About XML to JSON

Working with an XML feed or API from JavaScript is much easier once it is JSON. Paste the XML and get the same data as JSON objects and arrays.

Attributes are kept as keys starting with @_, and element text that sits next to attributes is stored under #text. Repeated elements with the same name become an array. The XML declaration and processing instructions are left out.

How to use it

  1. Paste your XML into the Input panel, or Open an .xml file.
  2. Check that the Output dropdown says Convert to JSON.
  3. Fix any XML error shown in Problems. Click it to jump to the spot.
  4. Copy the JSON or Download it.

Frequently asked questions

Are XML attributes kept?

Yes. An attribute such as id="1" becomes "@_id" in the JSON object of its element.

Why is one element an object and another an array?

An element that appears once becomes a single value; one that repeats becomes an array. If a list sometimes has one item, check for both shapes in your code.

Are numbers converted?

Yes. Text that looks like a number, such as 1984, becomes a JSON number.

Related tools