go-supertools
Developer & Data Tools

XML to JSON

Convert XML into a JSON structure in your browser.

Runs in your browser Your input never leaves your device.

0 characters | 0 words

About this tool

Paste XML and get JSON that mirrors its structure, wrapped in the root tag name. An element with child elements becomes an object and repeated child tags with the same name become an array. Attributes are kept with an @ prefix (<item id="2"> gives "@id": "2"), and text that sits next to attributes or between child elements is kept under "#text". An element with only text and no attributes becomes a plain string. CDATA text is included. The parsing uses your browser's built-in XML parser, so nothing is uploaded, and invalid XML shows an error message. All values stay as strings and comments are ignored.

How to use it

  1. Paste a complete XML document with one root element.
  2. Read the JSON in the output.
  3. Fix the error message if the XML is not well-formed.
  4. Press Copy to use the JSON.

Example

Input
<note><to>Ann</to><to>Bo</to><body>Hi</body></note>
Result
{
  "note": {
    "to": [
      "Ann",
      "Bo"
    ],
    "body": "Hi"
  }
}

Common problems

Why is there an @ in front of a key?
Keys starting with @ are XML attributes, and "#text" holds the text of an element that also has attributes or child elements.
Invalid XML message
Every tag must be closed, tags must nest correctly, and there must be one root element. Special characters such as & need to be written as &amp;.
Numbers appear as strings
All values are text. Convert types afterward in your own code.