Developer Tools

Converters

XML to JSON Converter

Turn an XML document into JSON.

XML0 chars
JSON

Guide & explanation

The XML to JSON Converter turns an XML document into a JSON object.

Mapping rules

XMLJSON
Attribute id="1"Property "@id": "1"
Text in a mixed elementProperty "#text"
Repeated elements with the same nameArray
Element containing only textA plain string value

Example

<book id="bk1"><title>XML</title><tag>a</tag><tag>b</tag></book>
{ "book": { "@id": "bk1", "title": "XML", "tag": ["a", "b"] } }

Options

  • Detect numbers & booleans — converts text 42 / true into JSON types. Turn it off to keep everything as strings.

XML has no notion of arrays or numbers, so a round-trip is not always identical.