XML to JSON Converter

Work with XML, YAML, spreadsheet data, and developer utilities locally in your browser.

How the XML to JSON converter works

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.

When to use it

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.

Worked example

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.

How XML constructs map to JSON

XMLJSON result
Repeated sibling elementsArray of values, in order
Element with text onlyString
Element with child elementsNested object
Attribute (id="1")Not included
Namespace prefix (ns:tag)Kept literally in the key

Are XML attributes included in the JSON?

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.

Why are my numbers and booleans quoted?

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.

What happens to repeated elements?

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.

Is my XML uploaded anywhere?

No. Parsing uses the browser's DOMParser and runs entirely on this page. The document never leaves your device.

XML Beautifier XML to CSV XML to YAML XML Validator JSON Viewer