All tools (39)
XML to JSON
Convert XML into JSON, keeping attributes and repeated elements.
Indent
Paste XML, an RSS feed or an SVG to convert it to JSON.
XML to JSON
Paste XML - a config file, a SOAP response, an RSS feed, an SVG - and get JSON. Parsing uses the browser's own XML parser, so what counts as well-formed here is exactly what counts as well-formed everywhere else.
How the two models are bridged
- Attributes become keys prefixed with
@, so they cannot collide with a child element of the same name. - Repeated elements become an array. Three
<item>children produce a three-element array; one produces a single object. That asymmetry is unavoidable - XML does not distinguish "a list of one" from "one thing" - so code reading the output should handle both. - Mixed content - an element with both text and child elements - puts the text under
#text.
Type conversion
Everything in XML is text. With convert numbers and booleans on, values that look numeric or boolean are converted; off, they stay strings. Off is the safer default when identifiers and version numbers are involved.
Malformed XML
If the document does not parse you get the parser's own error message rather than a partial result, because a half-parsed XML document is worse than none.
Related tools
- JSON to XML - the other direction.
- JSON Formatter - tidy the output.
- JSON to TypeScript - types for the result.