XML to JSON
Convert XML data structures to JSON format effortlessly.
Loading Smart Logic...
Quick Tip
Paste your XML, including the root element.
About This Tool
Why use XML to JSON?
Paste XML and get the equivalent JSON structure. Elements become object keys, attributes are prefixed with @, repeated sibling elements become arrays, and text inside an element that also has attributes is kept under #text.
The two formats do not map perfectly onto each other, which is why those conventions exist: XML distinguishes attributes from child elements and allows mixed content, while JSON has neither concept. Invalid XML is reported rather than partially converted, so a missing closing tag produces an error instead of silently truncated output.
Key Benefits
Attributes preserved
They are kept with an @ prefix instead of being dropped, so no information is lost.
Repeated elements become arrays
Two or more siblings with the same name are collected into a list, which is what consuming code expects.
Validation built in
Malformed XML produces a clear error rather than half-converted output.
How to use XML to JSON
- 1
Paste your XML, including the root element.
- 2
The JSON equivalent appears immediately.
- 3
Check how attributes (@) and repeated elements (arrays) were mapped.
- 4
Copy or download the JSON.
Best use cases
Convert a legacy XML API response for use in a JavaScript app.
Turn an RSS or sitemap file into JSON for processing.
Inspect a SOAP payload in a more readable form.
Migrate XML configuration to a JSON-based format.
XML to JSON FAQs
How are XML attributes represented in JSON?
As keys prefixed with @. So <user id="7"> becomes { "@id": "7" } inside the user object.
What happens to repeated elements?
They become an array. Three <item> elements under the same parent produce a list of three entries.
Why does my XML fail to convert?
It is not well-formed — usually an unclosed tag, a missing root element, mismatched case or an unescaped & (which must be written as &).
Are all values strings?
Yes. XML has no type information, so numbers and booleans come through as strings. Convert them in your own code where needed.
Related Developer Tools
More free developer tools that work well alongside xml to json.