XML to JSON Converter
Convert XML into nested JSON with attributes, arrays, and simple type coercion.
XML to JSON Converter
Convert XML documents into readable JSON in the browser. Repeated child elements become arrays, attributes can be preserved, and simple values can be converted into numbers, booleans, or null.
Conversion rules
- Attributes are stored with an @ prefix
- Text mixed with child nodes is stored as #text
- Repeated sibling tags become JSON arrays
How to use XML to JSON Converter
The XML to JSON converter turns XML documents into nested JSON. It helps when you need to inspect XML data with JSON tools or JavaScript code.
Developers often use this page when they need xml to json converter, xml converter in json, xml to json formatter, and convert xml to json.
Privacy and data handling
This tool is designed to run in your browser for normal use, so your input does not need to be sent to a server.
- Input and output stay on the page while you work.
- Copy buttons use your browser clipboard permission when available.
- Avoid pasting private production data on shared or untrusted devices.
Examples
Convert XML to nested JSON
Input
<user id="1"><name>Ada</name></user>Output
{
"user": {
"id": "1",
"name": "Ada"
}
}Attributes and repeated elements may need review after conversion.
Steps
- 1Paste a valid XML document.
- 2Convert it into JSON.
- 3Review attributes, text nodes, and nested elements.
Common use cases
- Convert an XML API response for JavaScript use.
- Inspect old XML data with JSON tooling.
- Create test fixtures from XML samples.
Practical tips
- XML attributes may become special JSON fields.
- Repeated elements often become arrays.
- Validate XML first if conversion fails.
FAQ
Can XML always become clean JSON?
Not always. XML has attributes, text nodes, namespaces, and repeated elements, so the JSON structure may need cleanup.
Why did one XML element become an array?
Repeated elements usually map to arrays in JSON because there can be more than one value.