curly{bits}

curlybits / XML to JSON

XML to JSON Converter

Paste XML to get the same data as JSON. Attributes, nested elements, repeated tags and mixed text are all converted in a predictable way, and invalid XML shows the exact line of the error.

Input XML
JSON output

      

How to use the XML to JSON Converter

  1. Paste XML into the left box, or click Load sample.
  2. The JSON appears on the right as you type.
  3. Tick Detect numbers & booleans to turn <price>120</price> into a number.
  4. Choose the indent and click Copy.

How XML maps to JSON

XMLJSON
<name>Ann</name>"name": "Ann"
Attribute id="7""@id": "7"
Text next to attributes or child elements"#text": "…"
The same element repeatedAn array: "item": [ … , … ]
Empty element <note/>"note": null

This is the common "@ and #text" convention used by many libraries, so the JSON converts back to the same XML with the other tool.

Frequently asked questions

Is my XML uploaded?

No. It's parsed by your browser's own XML parser.

Why is one element an array and another not?

Elements that appear more than once under the same parent become arrays. A single element stays a plain value. Tick Always use arrays for a consistent shape.

What happens to namespaces?

Prefixes are kept as part of the name, like "soap:Body", and xmlns declarations become @ attributes.

Updated

Add this XML to JSON converter to your website

Free for blogs, schools and businesses. Copy the code below and paste it into your page's HTML. The tool works exactly like this one and runs in your visitors' browsers, so nothing is uploaded. Please keep the credit line so others can find it too.

Preview embed ↗