Convertools Dev
All tools

Convert XML to JSON

Turn an XML document into JSON you can use in code.

XML input

Paste text or drop a file here (up to 50 MB).

JSON result

Free to use. Your input stays in this browser.

How to use it

  1. Paste XML or drop an .xml file.
  2. Choose the JSON indentation.
  3. Copy the result or download it as a .json file.

Mapping: attributes become "@name" keys and element text becomes a string. Text next to attributes or child elements goes in a "#text" key, elements with the same name become an array, and <empty/> becomes null.

Values stay strings, so 007 and 1.50 do not change. Comments and processing instructions are left out of the JSON.

Example

XML input
<?xml version="1.0" encoding="UTF-8"?>
<!-- Sample catalog -->
<catalog><book id="b1" lang="en"><title>XML Basics</title><price currency="USD">29.99</price><tags><tag>xml</tag><tag>data</tag></tags></book><book id="b2"><title><![CDATA[Fish & Chips <Guide>]]></title><price currency="EUR">12.50</price><note>Ships in <b>2 days</b>.</note></book></catalog>
JSON result
{
  "catalog": {
    "book": [
      {
        "@id": "b1",
        "@lang": "en",
        "title": "XML Basics",
        "price": {
          "@currency": "USD",
          "#text": "29.99"
        },
        "tags": {
          "tag": [
            "xml",
            "data"
          ]
        }
      },
      {
        "@id": "b2",
        "title": "Fish & Chips <Guide>",
        "price": {
          "@currency": "EUR",
          "#text": "12.50"
        },
        "note": {
          "b": "2 days",
          "#text": [
            "Ships in",
            "."
          ]
        }
      }
    ]
  }
}