XML to JSON
Convert XML to JSON as you type. Attributes, repeated elements and text are all kept, and any error shows its line and column.
Your files stay on your device. Nothing is uploaded.
Step 1: Paste or open your XML
Step 2: Options
Step 3: Copy or download
How to convert XML to JSON
-
Paste or open your XML
Paste XML into the first box, or click Open a file. The conversion runs as you type.
-
Choose the options
Choose the JSON layout, from 2 spaces to one line, and whether to keep XML attributes.
-
Copy or download
Click Copy JSON, or Download .json for a file.
About this tool
How XML maps to JSON
| XML | JSON |
|---|---|
| <city>Lahore</city> | "city": "Lahore" |
| <item id="7">Tea</item> | "item": {"@id": "7", "#text": "Tea"} |
| Two or more <item> elements | "item": [ ... ] (a list) |
Values stay exactly as written
XML has no number or true/false types, so every value stays text: "007" stays "007" and "1.50" stays "1.50". The XML declaration and processing instructions are left out, as JSON has no place for them.
Errors you can fix
If the XML is not well formed, such as a tag that is never closed, the message gives the line and column, for example "Line 3, column 5: Expected closing tag".
Privacy
This tool runs in your browser, on your own device. Your files and text are not uploaded to our server and we cannot see them. When you close or reload this tab, they are cleared, along with the results.
Frequently asked questions
Can I convert JSON back to XML?
Yes, with JSON to XML, which turns @keys back into attributes.
Does it handle namespaces?
Yes. Prefixed names such as soap:Body are kept as they are in the keys.
Is my data sent anywhere?
No. The conversion runs in your browser.
Is there a size limit?
Files up to 20 MB. Very large text may take a moment to convert.
Related tools
- JSON › XML JSON to XML Convert JSON to well-formed XML as you type.
- YAML › JSON YAML to JSON Convert YAML to JSON as you type, with clear errors.
- JSON › YAML JSON to YAML Convert JSON to clean, readable YAML as you type.
- JSON › CSV JSON to CSV Turn a JSON list of objects into a CSV table.
- JSON › XLSX JSON to Excel Turn a JSON list of objects into an Excel sheet.
- CSV › JSON CSV to JSON Turn a CSV table into a JSON array of objects.
- XLSX › JSON Excel to JSON Turn an Excel sheet into a JSON list of objects.
- Image › text Image to Base64 Turn an image into a Base64 data URI for code.