XML to JSON

Convert XML to JSON

About XML to JSON

Converts an XML document into JSON using the compact convention of the xml-js library: attributes go under _attributes, text content under _text, and repeated elements become arrays. Everything runs in your browser.

When you would use it

How to use it

  1. Paste the XML into the left field. Invalid XML is flagged with an error.
  2. Read the JSON on the right.
  3. Copy the result.

Things worth knowing

Frequently asked questions

Why is the same element sometimes an object and sometimes an array?
The converter cannot know which elements are meant to repeat. One occurrence gives an object, two or more give an array. Normalise with something like [].concat(value) in your code.
Why do my numbers appear as strings?
XML carries no type information, so every value is text. Convert to numbers or booleans in the consuming program.

All the tools