HTML Formatter
Beautify and indent HTML markup.
OpenConvert an XML document to JSON, keeping attributes and turning repeated elements into arrays.
Add a feed, API response or config document.
Malformed XML is rejected with an Invalid XML message.
Children become keys, repeats become arrays, attributes go under @attributes.
Copy the converted object or download it as data.json.
You are moving an integration off an old XML endpoint and want to see how its responses would look as JSON objects. Converting a few real samples shows you the shape before you write any mapping code.
The input is parsed with the browser's DOMParser in strict XML mode, so a mismatched tag or unescaped ampersand stops the conversion with an Invalid XML message instead of producing partial output. The root element becomes the top-level key. Child elements become nested keys, and when the same element name appears more than once under a parent, its values are collected into an array. Attributes are placed in an @attributes object, and an element that has attributes but only text gets that text under #text. The JSON is indented and downloads as data.json.
All values are strings, since XML has no number or boolean types. Text mixed with child elements, as in <p>Hello <b>world</b></p>, keeps only the child elements, so the converter suits data documents better than prose markup. Namespace prefixes stay in key names, for example soap:Body. You can query the converted JSON with JSONPath, reverse the process with JSON to XML, or indent the source first using the XML pretty printer.
The DOMParser used here is part of your browser, so the document is converted without contacting any server.
Keyboard shortcut
Answers for this tool. For site-wide help, open the FAQ hub.
Arrays are created only when a name repeats under the same parent. A list with a single item comes out as a plain value. If your code expects arrays, normalize those keys after conversion.
No. Only elements, attributes and non-empty text are converted. Comments, the XML declaration and processing instructions are dropped.
An empty element without attributes becomes an empty string. With attributes, it becomes an object holding @attributes and an empty #text.