Hand-rolled XML-to-JSON converters usually work fine right up until they
meet real-world XML — repeated sibling tags, attributes, CDATA, a stray
unclosed tag. Our new
XML to JSON Converter sidesteps all of
that by leaning on the browser’s own DOMParser instead of scanning the
raw text for tags itself.
- Repeated elements become arrays, correctly — three sibling
<item>tags become a three-item array, not just the last one silently overwriting the others. This is the single most common bug in hand-written XML-to-JSON logic. - Attributes land under
@attributes— kept separate from child elements so nothing gets confused, with#textalongside it when an element has both attributes and text content. - Real parser, real error handling —
DOMParsernever throws a JavaScript error on malformed XML, it just returns a document containing a<parsererror>element instead. This tool checks for exactly that and shows a plain-language message rather than a blank box or a confusing crash. - Namespaces and CDATA just work — because they’re resolved by the browser’s actual XML parser, not approximated by a regular expression.
- Private by default — parsing and JSON building happen entirely in your browser; nothing you paste is ever sent to a server.
Need to go the other direction? The new JSON to XML Converter builds well-formed XML from JSON using the DOM’s own element and text APIs, so escaping is handled correctly by construction instead of by string concatenation.