Convert XML to JSON online for free. Paste XML or upload a file, preserve nested data and attributes, then copy or download formatted JSON with ToleHub.
FREE DEVELOPER TOOL · PRIVATE BROWSER CONVERSION · NO API
Convert XML into readable JSON in seconds. Paste XML or upload a local file, preserve attributes and repeated elements, then copy or download your result. Your XML stays in your browser.
Input XML
Paste an XML document, or select a .xml file.
Maximum input: 2 MB. DTD/entity declarations are blocked for safety. No remote requests or account required.
JSON Output
Clean, valid JSON generated locally.
How XML to JSON conversion works
Attributes
XML attributes become keys starting with @. Example: id="101" becomes "@id": "101".
Repeated elements
Sibling tags with the same name become a JSON array. For example, two <order> nodes become "order": [ ... ].
Text and nested nodes
Simple elements become strings. If an element also has attributes or children, its own text is kept in #text. Tag and attribute names keep their XML case.
Privacy and safety: This converter runs in your browser using DOMParser, not a server API. For security, document type declarations and custom entity declarations are rejected. Convert only XML you are permitted to process.
How to convert XML to JSON online
To convert XML to JSON online, start by pasting valid XML into the input area or uploading a supported XML file. Use a small sample first if you are unfamiliar with the format.
Run the conversion, then review the resulting JSON before copying it or downloading the file. Pay attention to attributes, nested elements and repeated tags, because their structure may differ from the original XML.
If the converter reports an error, check matching closing tags, quotation marks around attribute values and properly escaped special characters.
For a worked example, see the XML to JSON tutorial. If you need spreadsheet rows afterward, consider the JSON to CSV converter.
How to read attributes and repeated elements in JSON
In the converted JSON, XML element names become property keys. Attributes are represented with an @ prefix, so sku="N-100" can appear as "@sku": "N-100". Repeated sibling tags become arrays, while numeric-looking XML text may remain a string. Check the output structure and data types before importing it into another application.
Example: a product record
Imagine a simple XML record: <item sku="N-100"><name>Notebook</name><stock>12</stock></item>. After converting it, you can inspect the item’s name, stock and SKU in the JSON output. The stock value comes from XML text, so check whether your receiving application needs it converted from the string "12" into the number 12.
Common XML conversion mistakes
- Unclosed tags: XML needs matching opening and closing tags. A missing closing tag can stop conversion.
- Ignoring attributes: Values inside a tag, such as an item’s SKU, are different from child elements. Check where they appear in JSON.
- Assuming text becomes numbers: A value like
12may remain a string and need converting in your application. - Expecting repeated tags to become separate property names: They may be grouped into a JSON array. Check this before processing multiple records.
XML to JSON FAQ
Can I upload an XML file?
Yes. You can paste XML or upload a supported XML file, then copy or download the converted JSON.
Why does my XML show an error?
Check for missing closing tags, incorrectly quoted attributes and special characters that need escaping.
What happens to XML attributes?
Attributes are represented separately from child elements in the resulting JSON. Check the output’s property names before reusing it.
Will the converter turn stock counts into numbers?
XML content is text, so numeric-looking values can remain strings in JSON. Convert them to numbers in your application if necessary.
Can I get a CSV file from XML?
Convert XML to JSON first. If the result can be represented as rows and columns, you can then use ToleHub’s JSON to CSV Converter.
Review converted files before importing them into production systems.
Need a worked example? Follow our step-by-step guide to converting XML to JSON for nested elements, attributes and common error fixes.
