XML to JSON
Convert XML to JSON in your browser. Attributes become @keys, repeated elements become arrays, and numbers can be typed. Free XML to JSON converter, no upload.
Runs in your browser. Nothing is uploaded.
About XML to JSON
XML to JSON turns an XML document into a JSON object you can use in JavaScript or send to a JSON API. Elements become keys, repeated sibling elements become arrays, and attributes are kept as keys prefixed with @ so they can't clash with child elements.
Elements that have both attributes and text put the text under #text. Number and boolean conversion is optional: switch it off to keep every value as a string, which is safer for IDs and postcodes with leading zeros.
The document is checked first, so malformed XML gives you a line and column rather than half-converted output.
How to use XML to JSON
- Type or paste your text into the input box. Press Sample to see an example.
- Adjust the options. The result updates as you type.
- Copy the result, or press Use as input to chain another transformation.
Frequently asked questions
How are attributes shown?
As keys starting with @, for example <book id="7"> becomes {"book": {"@id": 7}}. Untick the option to drop attributes.
Why is a single child an object but two children an array?
XML doesn't say whether an element can repeat, so one occurrence is an object and several become an array. Check your code handles both.
Is XML to JSON free and private?
Yes. XML to JSON is completely free with no sign-up. Everything runs in your browser, so whatever you type or paste never leaves your device.