XML to JSON Converter
Convert XML to JSON
What Is This Tool?
The XML to JSON Converter turns an XML document into an equivalent JSON structure. Elements become object keys, attributes are grouped under an @attributes key, repeated child tags become arrays, and text-only elements become plain string values. Conversion happens entirely in your browser using the built-in DOMParser — nothing is uploaded.
How to Use
Paste your XML into the input box.
Click Convert to generate the JSON equivalent.
Review the pretty-printed JSON output.
Copy the result or download it as a .json file.
Features
- Attributes preserved under an @attributes key
- Repeated child elements automatically become arrays
- Text-only elements collapse to plain string values
- Pretty-printed, 2-space indented JSON output
- Copy to clipboard or download as a file
- 100% client-side — nothing leaves your browser
Examples
Input XML:
<catalog>
<item id="1">
<name>Widget</name>
</item>
<item id="2">
<name>Gadget</name>
</item>
</catalog>
Output JSON:
{
"catalog": {
"item": [
{ "@attributes": { "id": "1" }, "name": "Widget" },
{ "@attributes": { "id": "2" }, "name": "Gadget" }
]
}
}
Common Use Cases
- Migrating legacy XML feeds or configs to a JSON-based API
- Inspecting an XML payload's structure in a more familiar JSON form
- Preparing XML data for a JavaScript application that expects JSON
- Quickly comparing XML and JSON representations of the same data
Frequently Asked Questions
Is my XML uploaded anywhere?
No. Conversion happens locally in your browser using the built-in DOMParser. Nothing is sent to a server.
How are XML attributes represented in the JSON?
Each element's attributes are placed in an @attributes object alongside its other child data, so you can distinguish attributes from child elements.
What happens with repeated child elements?
If an element has multiple children with the same tag name, they are combined into a JSON array in the order they appear.
What if my XML isn't well-formed?
The converter shows the browser parser's error message so you can fix the XML before converting it.
Are XML comments and processing instructions included?
No, only element, attribute, and text content is converted. Comments and processing instructions are ignored.
Can I download the converted JSON?
Yes, click Download to save the current output as a data.json file.