Transcode
Docs
Inputxml
OutputJSON

XML to JSON

Format XML for readability or convert it to JSON.

Paste your input on the left and press Translate (or Ctrl/Cmd + Enter) to get the result on the right. Free, no sign-up.

Example

Input
<?xml version="1.0" encoding="UTF-8"?>
<library><book id="1" available="true"><title>Dune</title><author>Frank Herbert</author><year>1965</year></book><book id="2" available="false"><title>Neuromancer</title><author>William Gibson</author><year>1984</year></book></library>
Output
{
    "?xml": {
        "@_version": 1,
        "@_encoding": "UTF-8"
    },
    "library": {
        "book": [
            {
                "title": "Dune",
                "author": "Frank Herbert",
                "year": 1965,
                "@_id": 1,
                "@_available": true
            },
            {
                "title": "Neuromancer",
                "author": "William Gibson",
                "year": 1984,
                "@_id": 2,
                "@_available": false
            }
        ]
    }
}

Frequently asked questions

How are XML attributes represented in JSON?
Attributes become properties prefixed with @_, which keeps them apart from child elements.
Can it fix invalid XML?
No. Malformed XML such as unclosed tags will return an error.