Convert XML to JSON
More data converters: JSON to Excel · JSON to CSV · CSV to JSON · Excel to JSON · JSON to XML · XML to Excel · YAML to JSON · JSON Formatter
How to Convert XML to JSON
Feeds, sitemaps, configuration files, API responses or exports. Click Example to see the mapping.
Keep the @ in front of attribute names or drop it, and decide whether numbers should become JSON numbers.
Copy the JSON or download it as a .json file.
How XML maps to JSON
The rules this converter uses
| XML | JSON |
|---|---|
<title>Rain</title> | "title": "Rain" |
<book id="bk1"> | "@id": "bk1" inside "book" |
Two or more <book> under one parent | "book": [ {…}, {…} ] |
<price cur="EUR">5</price> | "price": {"@cur": "EUR", "#text": "5"} |
<note/> | "note": "" |
| The root element | The single top-level key, so its name is not lost |
- One or many: an element that appears once becomes a value, one that repeats becomes a list. If your code expects a list, check for both — this is the nature of XML, not of the converter.
- Attributes: the @ prefix keeps them apart from child elements with the same name. Switch it off for cleaner keys; if a name is used both ways, the attribute keeps the @.
- Numbers: XML has no types, so everything is text by default. "Detect numbers and true/false" turns
5.95into a number andtrueinto a boolean, but keeps values like007as text. - Namespaces keep their prefix (
"dc:title"). Comments and processing instructions are left out; CDATA sections become normal text. - Safe to paste: the XML is read by your browser's own parser, which does not fetch external entities or files.
Need the opposite direction? Use JSON to XML — it reads the same @ and #text keys back as attributes and text. For a spreadsheet, use XML to Excel.
Frequently Asked Questions
Is the XML uploaded anywhere?
No. It is parsed and converted in your browser. Nothing is sent to our server.
What do @ and #text mean in the JSON?
Keys starting with @ were attributes in the XML. #text holds the text of an element that also has attributes or child elements.
Why is one element an object and another a list?
Elements that appear several times under the same parent become a list; elements that appear once stay a single value.
Can I convert the JSON back to XML?
Yes. JSON to XML turns @ keys back into attributes and #text back into element text, so the structure survives the round trip.