About this XML to JSON converter
XML and JSON both store structured data, but modern code almost always prefers JSON: it is lighter, it maps straight onto objects and arrays, and every language parses it natively. This tool converts XML into clean, readable JSON right in your browser, so the document you paste is never uploaded.
It uses the browser’s own XML parser, the same one web pages rely on, which means it understands real-world XML: nested elements, attributes, and text content. If the input is not well-formed XML, the tool tells you instead of guessing.
How the conversion is structured
XML has a few features JSON does not, so the converter uses simple, predictable rules to bridge them.
- Elements become object keys.
<user><name>Ada</name></user>turns into{ "user": { "name": "Ada" } }. - Attributes are kept and prefixed with
@, so<user id="42">becomes{ "@id": "42" }. That way an attribute never collides with a child element of the same name. - Repeated elements become an array. Three
<item>tags under one parent turn into a list, which is what you want for iterating in code. - Text inside an element that also has attributes is stored under a
#textkey, so nothing is lost.
Things to keep in mind
Every value comes out as a string, because XML has no types. The number 42 in XML is just text, so it arrives as "42" in the JSON, and you cast it in your code if you need a real number. This is normal for XML conversion and keeps the output faithful to the source.
XML comments, processing instructions, and namespaces prefixes are simplified away, since JSON has no equivalent for them. If you need a byte-perfect, round-trippable transform, a dedicated XML library in your language is the better tool. For reading an XML feed or config and pulling the data into JavaScript, this converter is the fast path.