XML to JSON converter
Turn XML documents into clean JSON.
Runs in your browser. Nothing you type is sent anywhere.
- Keeps attributes
- Repeated tags become arrays
- Exact error location
How to convert XML to JSON
- Paste your XML or upload the file.
- Keep or drop attributes with the checkbox.
- Copy the JSON or download it.
Example: XML in, JSON out
| XML | JSON |
|---|---|
| <name>Sam</name> | {"name":"Sam"} |
| <item id="5">Widget</item> | {"item":{"@_id":"5","#text":"Widget"}} |
| <tag>a</tag><tag>b</tag> | {"tag":["a","b"]} |
What XML to JSON keeps
- Attributes, when the checkbox is on, as keys starting with @_.
- Text content alongside attributes under a #text key, when an element has both.
- Repeated sibling tags as a JSON array, in document order.
- Numbers with a leading zero, like 007, kept as text so IDs are never changed.
Common causes of malformed XML
- An unclosed or mismatched tag.
- A bare & or < inside text that should be written & or <.
- Two elements at the top level, since well-formed XML allows only one root.
Where XML to JSON helps
- Reading an older SOAP API response inside a modern, JSON-based frontend.
- Converting an RSS or Atom feed into JSON for a script to loop over.
- Inspecting a config file exported from enterprise software that only speaks XML.
- Checking what a legacy system's export actually contains before writing a full import pipeline for it.
XML to JSON FAQ
What happens to XML attributes?
They are kept as fields whose names start with @_, so id="5" becomes "@_id": "5". Turn off include attributes to leave them out.
How are repeated elements handled?
Sibling elements with the same tag name become a JSON array. A tag that appears only once stays a single value.
Are numbers converted?
Plain numbers like 42 become JSON numbers. Values with a leading zero, such as 007, stay text so codes and IDs are not changed.
Why does it say my XML is malformed?
Usually a tag is not closed, a closing tag does not match, or text contains a bare ampersand that should be written as &. The error names the line and column.
Are XML namespaces kept?
The namespace prefix stays as part of the tag name, such as ns:id becoming a key literally called ns:id, since the converter does not resolve namespace URIs into anything else.
What happens to a self-closing tag like <br/>?
It becomes an empty string value, the same result you would get from the longer <br></br>.
What happens to XML comments?
They are dropped. JSON has no comment syntax to carry them into, so only the element data converts.
Can it convert an XML file that has a DOCTYPE?
Yes, the DOCTYPE is read and then left out of the JSON output, since it only controls XML validation and has no data of its own to carry over.