XML to JSON Converter
Convert XML to JSON - nested elements become nested objects, attributes are preserved, repeated elements become arrays.
Paste or upload XML below - this tool parses it with your browser's built-in, safe XML parser and converts the structure to JSON.
More File & Data Conversion Tools
View all 20External entities and DTD-based network requests are never resolved by this tool - browser XML parsing is inherently safe against XXE-style attacks by default.
How the Conversion Works
Each XML element becomes a JSON object key; attributes are captured under an @attributes key; repeated sibling elements with the same name become a JSON array; an element's plain text content becomes its value (or a #text key when the element also has attributes/children).
How to Use It
- Paste or upload XML data.
- Click Convert.
- Copy or download the resulting JSON.
Security Notes
XML parsing here uses the browser's native DOMParser, which does not fetch external DTDs or resolve external entities - your XML is never used to make outbound network requests, protecting against XXE-style attacks.
Example
<book id="7">
<title>Dune</title>
<tag>sci-fi</tag>
<tag>classic</tag>
</book>
becomes a structure like:
{
"book": {
"@attributes": {
"id": "7"
},
"title": "Dune",
"tag": [
"sci-fi",
"classic"
]
}
}
The attribute is kept under @attributes, and the two <tag> elements become an array.
Common Uses
- Working with SOAP responses, RSS/Atom feeds or sitemaps in JavaScript.
- Migrating data from an XML-based system to a JSON API or document database.
- Reading a large XML document more easily - JSON is often shorter.
Things to Watch
- An element that appears once becomes a single value, and the same element repeated becomes an array. If your code expects an array, handle both shapes.
- All values are text in XML, so
"1965"stays a string - convert types in your code. - Namespaced names such as
dc:creatorkeep their prefix as part of the key.
Convert back with JSON to XML. For a flat table, use XML to CSV.
Frequently Asked Questions
Explore More Tools
Keep going with related categories and our most used tools.