Parse and convert XML data into clean JSON format locally.
Loading tool
About XML to JSON
Validate an XML document and convert it to JSON. Repeated sibling elements become arrays, attributes can be written as prefixed keys, grouped under one key or ignored, and the key used for element text is configurable. Options parse numeric and boolean text into real numbers and booleans and can wrap every element in an array for a predictable shape. Comments and processing instructions are dropped.
Common uses
- Work with an XML API response or RSS feed in JavaScript
- Convert an XML config or export file into JSON for another tool
- Inspect the structure of a large XML document
- Find where an XML document is malformed
FAQ
- How are XML attributes represented in JSON?
- By default each attribute becomes a key with an @_ prefix, such as "@_id": "1". You can change the prefix, group all attributes under one key such as @attributes, or ignore them.
- Why is an element sometimes an array and sometimes an object?
- An element that appears once becomes an object, while repeated siblings become an array. Enable the always-use-arrays option if your code needs the same shape regardless of how many elements there are.
- Are numbers kept as strings?
- XML text has no types. With number and boolean parsing on, values like 44.95 and true become JSON numbers and booleans; turn it off to keep every value as a string.