XML to JSON

Convert XML documents to JSON format.

Convert XML to JSON. Elements become keys, repeated elements become arrays, and attributes become keys with a prefix you choose (@id, _id or none). Numbers and true/false can be converted to JSON types, and you can make every child an array for a consistent shape that's easier to work with in code. The XML is parsed first, so you'll get a clear error if it isn't well formed. Conversion runs in your browser.

Common use cases

  • Use data from a SOAP or legacy XML API in JavaScript
  • Convert an RSS feed or sitemap to JSON
  • Turn XML config into JSON for a new system
  • Inspect XML data in a more compact form

How to use

  1. Paste the XML, or press Try an example.
  2. Choose the attribute prefix and type conversion.
  3. Tick Always use arrays if your code expects them.
  4. Copy or download the JSON.

FAQ

How are attributes handled?

<book id="1"> becomes "book": { "@id": 1 } with the default prefix. Change the prefix to _ or none to suit your code.

Why is one element an object and another an array?

A single child becomes an object and repeated children become an array. Tick Always use arrays so every child is an array, whatever the count.

Can I convert back?

Yes, with the JSON to XML converter, though attribute and array details may come out differently.