XML to JSON Converter
Work with XML, YAML, spreadsheet data, and developer utilities locally in your browser.
Work with XML, YAML, spreadsheet data, and developer utilities locally in your browser.
The converter parses your XML with the browser's built-in DOMParser and then walks the element tree. Every child element becomes a key on a JSON object. When the same tag name repeats inside one parent, the values collapse into a JSON array in document order. An element that has no child elements is emitted as a string holding its trimmed text content. The document's root element is unwrapped, so the top level of the JSON is the root's contents. Only element names and text are kept — attributes and namespace prefixes are not carried into the output.
Reach for this when you need to work with an XML SOAP or REST response in JavaScript, move a legacy config file or an RSS/Atom feed into a JSON pipeline, or just read a dense XML payload as an indented JSON tree.
Input:
<catalog>
<book><title>Dune</title><year>1965</year></book>
<book><title>1984</title><year>1949</year></book>
</catalog>
Output:
{
"book": [
{ "title": "Dune", "year": "1965" },
{ "title": "1984", "year": "1949" }
]
}
Note that <catalog> is unwrapped, the repeated <book> becomes an array, and 1965 stays a string.
| XML | JSON result |
|---|---|
| Repeated sibling elements | Array of values, in order |
| Element with text only | String |
| Element with child elements | Nested object |
Attribute (id="1") | Not included |
Namespace prefix (ns:tag) | Kept literally in the key |
No. This converter emits element names and text content only. If you need attribute values, restructure them as child elements before converting, or use an attribute-aware parser.
Every leaf value is read as text, so <year>1965</year> becomes the string "1965". Cast values to the types you need after parsing the JSON.
The first occurrence is stored as a plain value; each further sibling with the same tag name turns the entry into an array and appends to it, preserving order.
No. Parsing uses the browser's DOMParser and runs entirely on this page. The document never leaves your device.