XML to JSON Converter
Parse XML documents and feeds into JSON.
XML
JSON
About the XML to JSON converter
Paste an XML document — an RSS feed, a SOAP response, a configuration file — and read it as JSON. Elements become keys, repeated elements become arrays, and attributes are preserved with a prefix.
Malformed input produces a specific message: which tag was left open, or which closing tag did not match, rather than a generic failure.
How attributes and text are represented
An element with only text content becomes that text directly. An element with attributes becomes an object, with each attribute keyed by the prefix you choose plus its name — `@id` by default.
When an element has both attributes and text, the text is stored under `#text` alongside the attribute keys.
Repeated elements
Two sibling elements with the same name become an array. One element on its own does not, because there is no way to tell from a single document that it is a collection. That asymmetry is inherent to XML, not a limitation of the converter — if it matters, normalise the shape after converting.
What is stripped
The XML declaration, comments, DOCTYPE declarations and processing instructions are discarded. CDATA sections are unwrapped and their contents kept as text.
Frequently asked questions
Why is one item an object and a list of them an array?
XML does not distinguish a one-item list from a single value. If your consumer needs consistency, coerce that key to an array after conversion.
Are namespaces supported?
Prefixed names such as `soap:Body` are kept verbatim as keys. The namespace declarations themselves come through as ordinary attributes.
Can I convert an SVG file?
Yes — SVG is XML. It is a handy way to inspect the structure of an icon.