About XML to JSON
This turns XML into JSON so you can work with legacy or enterprise data in a modern, code-friendly shape. When you're pulling from a SOAP API, an RSS feed, an XML config or an old export and the rest of your stack speaks JSON, this does the translation — paste the XML and get an indented JSON object back.
How it works
The XML is parsed with the browser's built-in DOM parser, then converted to JSON:
- Elements become object properties keyed by tag name.
- Attributes are preserved with an
@prefix (an attributeidbecomes"@id"). - Repeated child elements with the same tag name become a JSON array.
- An element with only text and no attributes becomes a plain string; if it has attributes too, the text is stored under
"#text".
If the XML is malformed, the parser reports an error rather than producing broken JSON.
Assumptions and behaviour
- Attributes are prefixed with
@and text content of mixed nodes is stored as#text, a common convention that keeps attributes and elements distinguishable. - Repeated tags collapse into arrays; a tag appearing once is a single value, the same tag appearing multiple times becomes a list.
- Whitespace-only text is trimmed, so indentation in the source doesn't clutter the output.
- The root element name is kept as the top-level key.
Limitations
- Round-tripping isn't guaranteed. A tag that appears once becomes a single object while the same tag appearing twice becomes an array, so converting back to XML may not reproduce the original exactly.
- Mixed content is simplified. Elements that interleave text and child elements don't map neatly to JSON and may lose the text or its ordering.
- Element order isn't preserved the way it is in XML — JSON object keys don't carry document order for differing tags.
- Namespaces are flattened into the tag name as written; it doesn't resolve or separate XML namespaces.
- Comments, processing instructions and CDATA nuances aren't specially represented.
Privacy
Conversion runs entirely in your browser. Your XML and the resulting JSON never leave your device.

