Convert XML to JSON
Convert an XML document to JSON, detecting syntax errors before attempting the conversion.
Processed on your device. Nothing is sent to any server.
Validates the XML's structure and converts it to an equivalent JSON object, representing attributes with a distinctive prefix to tell them apart from element content.
Use cases
- Converting an old API's XML response to work with it as JSON.
- Debugging an XML document's structure.
- Migrating data from an XML format to JSON.
How it works
- 1
Paste your XML
Type or paste the XML document into the input box.
- 2
Convert it
Click Convert and copy or download the resulting JSON.
Technical details
- Attributes become keys prefixed with @_ and the text of an element with attributes goes under #text. Example: <item id="1">A</item> → {"@_id": "1", "#text": "A"}.
- Repeated elements with the same name become an array; a single one stays an object or value, so the JSON shape can change depending on how many there are.
- Plain numbers become numbers, but those with leading zeros (00123) stay as text.
- The XML is validated before conversion and external entities (DTD) aren't resolved, which prevents XXE-style attacks.
Frequently asked questions
What happens to XML attributes?
They're represented as keys with an @_ prefix inside the JSON object, to distinguish them from child element content.