XML to JSON Converter
Convert XML into clean, formatted JSON. Attributes, repeated tags and nested elements are all kept.
XML Input
JSON Result
What Is an XML to JSON Converter?
An XML to JSON converter reads an XML document and writes the same data as JSON. JSON is the format most web apps and APIs use today, so converting XML makes old feeds, config files and API responses easy to use in JavaScript, Python and other modern tools.
How to Convert XML to JSON
- Paste your XML into the XML Input box, click Upload, or drop a .xml file on the box.
- Click Convert to JSON, or press Ctrl + Enter.
- Check the colored JSON result, then click Copy or Download.
How the Conversion Works
- Every XML element becomes a JSON key with the same name.
- Attributes become keys that start with @, like "@id".
- Repeated elements, like several <book> tags, become a JSON array.
- Numbers and true/false become real JSON numbers and booleans (you can turn this off).
- Text next to child elements is kept under "#text".
Example
<product id="7" currency="GBP"> <name>Notebook</name> <price>4.50</price> <tag>paper</tag> <tag>office</tag> </product>
{
"product": {
"@id": 7,
"@currency": "GBP",
"name": "Notebook",
"price": 4.5,
"tag": ["paper", "office"]
}
}The attributes become @id and @currency, the two <tag> elements become an array, and 4.50 becomes the number 4.5.
Things to Watch Out For
- One item or many: an element that appears once becomes a single value, but twice becomes an array. If your code always expects an array, handle both cases.
- Codes that look like numbers: values such as ZIP codes or IDs with leading zeros (
00123) stay text, but other numbers are converted. Turn off type conversion to keep every value as text. - Namespaces: prefixed tags like
soap:Bodykeep their prefix in the key name.
Check messy XML first with the XML Formatter, and convert back with JSON to XML.
Frequently Asked Questions
Is this XML to JSON converter free?
Yes. It is free, needs no sign-up, and has no limits on how often you use it.
How are XML attributes converted?
Attributes become keys that start with @, for example <book id="7"> becomes {"book": {"@id": 7}}. Text next to child elements is stored under #text.
What happens to repeated tags?
When the same tag appears more than once inside a parent, the values are collected into a JSON array, so no data is lost.
Is my XML uploaded to a server?
No. The conversion runs completely inside your browser using its built-in XML reader.