XML to JSON converter

Paste an XML document and get JSON. Attributes become keys starting with @, text becomes #text, and repeated elements become arrays. Runs in your browser.

Runs in your browser

Convert XML to JSON

How XML maps to JSON

XML has elements, attributes and text, and JSON has objects, arrays and values. The converter uses these rules:

Example

<person id="1"><name>John</name><tag>a</tag><tag>b</tag></person> { "person": { "@id": "1", "name": "John", "tag": ["a", "b"] } }

Common uses

Questions

No. The conversion runs in your browser, so the XML you paste stays on your device.
Element and attribute names are kept as written in the source, including any prefix such as ns:name. Namespace URIs are not resolved.
The input must be well-formed. Check for an unclosed tag, an unescaped &, or more than one root element. The status line shows the first problem the parser reports.