XML to JSON Converter
Convert between XML and JSON formats with attribute handling.
How it works
- 1
Select direction
Choose XML to JSON or JSON to XML conversion.
- 2
Paste your data
Paste XML or JSON into the left panel. Output updates in real time.
- 3
Copy the result
Click Copy to copy the converted output.
Common use cases
Simple XML
<user><name>Alice</name><age>30</age></user>
XML with attributes
<item id="1" status="active">Widget</item>
About This Tool
Convert XML to JSON or JSON to XML instantly with this free online converter. The tool handles XML attributes by mapping them to JSON properties with a configurable prefix (default @_), so attributes like id="1" become "@_id": "1" in the output.
Supports nested elements, text content, CDATA sections, and mixed content. Toggle between XML-to-JSON and JSON-to-XML directions with a single click, and choose between pretty-printed or compact JSON output.
The converter uses the fast-xml-parser library and runs entirely in your browser -- your data is never sent to any server, making it safe for sensitive configuration files, API payloads, and production data.
More examples
Examples
Simple XML
Input
<user><name>Alice</name><age>30</age></user>
Output
{
"user": {
"name": "Alice",
"age": 30
}
}XML with attributes
Input
<item id="1" status="active">Widget</item>
Output
{
"item": {
"@_id": "1",
"@_status": "active",
"#text": "Widget"
}
}Frequently Asked Questions
- How are XML attributes handled?
- Attributes are converted to JSON properties with a configurable prefix (default @_). For example, <item id="1"> becomes {"@_id": "1"}. You can change the prefix in the options.
- Does it handle CDATA sections?
- Yes. CDATA content is extracted and included as a text value in the resulting JSON.
- Can I convert JSON back to XML?
- Yes. Toggle the direction to JSON→XML. The converter uses the same attribute prefix to reconstruct XML attributes from JSON properties.
- Is my data sent to a server?
- No. All parsing and conversion runs in your browser. Your data stays on your device.
Related Guides
Discover More Tools
View all Developer Tools →JSON Formatter & Validator
Format, validate, and prettify JSON instantly.
JSON to YAML Converter
Convert between JSON and YAML formats instantly.
JSON to CSV Converter
Convert JSON arrays to CSV with delimiter and flattening options.
Base64 Encode & Decode
Encode text to Base64 or decode Base64 to text.