Boneyard Tools

XML to JSON Converter

Paste XML to get clean JSON instantly. Attributes, nested elements, repeated tags, CDATA and entities are all handled, and your data stays in your browser.

How to convert XML to JSON

  1. Paste or type your XML into the input box.
  2. Choose options like value parsing or the attribute prefix if you need them.
  3. Copy the JSON or download it as a .json file.

Examples

Element with an attribute

<user id="1"><name>Ada</name></user>
{
  "user": {
    "@id": "1",
    "name": "Ada"
  }
}

Repeated tags become an array

<list><item>a</item><item>b</item></list>
{
  "list": {
    "item": [
      "a",
      "b"
    ]
  }
}

Frequently asked questions

Is my data uploaded anywhere?

No. The conversion runs entirely in your browser, so your XML never leaves your device.

How are XML attributes represented in the JSON?

Attributes become keys prefixed with @ by default, for example id="1" becomes "@id": "1". You can change or remove the prefix.

How are repeated XML elements handled?

Sibling elements that share a tag name are grouped into a JSON array. A tag that appears once stays a single value, not an array.

What happens to an element that has both text and attributes?

The text is stored under a "#text" key alongside the attributes, so nothing is lost. You can rename this text key.

Are numbers and booleans converted to real JSON types?

Only if you turn on value parsing. By default every value stays a string for fidelity, so ids and zip codes keep leading zeros.

Does it handle CDATA, comments and entities?

Yes. CDATA sections become literal text, comments and the XML declaration are skipped, and entities like &amp; and &#x1F600; are decoded.

What happens with invalid XML?

You get a clear error that points at the problem, such as a mismatched closing tag, an unclosed element or multiple root elements.

Related tools