XML to JSON converter
About XML to JSON
This XML to JSON converter turns an XML document into JSON. Paste an RSS feed, a SOAP response or a config file and get JSON you can read and use in JavaScript.
Attributes become keys with an @_ prefix and repeated elements become arrays. Use the swap control to convert JSON to XML instead.
Runs in your browser. Nothing is uploaded.
How it works
Elements become keys
Each element name becomes a JSON key and its text becomes the value. Nested elements become nested objects. The XML declaration is kept as a ?xml key.
Attributes
Attributes are written as keys with an @_ prefix, such as "@_id", so they never clash with child elements of the same name. Attribute values stay strings.
Repeated elements become arrays
When the same tag appears more than once under one parent, like several <role> elements, the values are grouped into a JSON array.
Numbers and booleans in text
Element text that looks like a number becomes a JSON number, and true or false becomes a boolean. Everything else stays a string.
Frequently asked questions
How are XML attributes shown in JSON?
As keys with an @_ prefix next to the child elements, for example {"@_id": "usr_8x42", "name": "Ada Lovelace"}.
Why is a list with one item not an array?
XML has no array type. One <role> element looks the same as a single field, so it becomes a plain value. Two or more become an array.
Does it keep XML comments?
No. Comments are not data and are dropped from the JSON.
How do I convert JSON to XML?
Click the swap control. Keys with an @_ prefix are written back as attributes.
Is my XML uploaded?
No. Parsing happens in your browser.
Sources & last verified
We checked this tool's behavior and the claims on this page against the specifications below on . The tool runs in your browser, so the output you see is exactly what the engine produced.
Found a wrong result or an outdated claim? Report an error and we will check it again.