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
- Paste the XML, or press Try an example.
- Choose the attribute prefix and type conversion.
- Tick Always use arrays if your code expects them.
- 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.
Related tools
- JSON to XMLConvert JSON data to XML document format.
- CSV to JSONConvert CSV data to JSON format for APIs and applications.
- YAML to JSONConvert YAML configuration files to JSON format.
- JSON to CSVConvert JSON arrays to CSV spreadsheet format.
- JSON to YAMLConvert JSON data to YAML configuration format.
- CSV Diff CheckerCompare two CSV files and highlight differences.