XML to JSON Converter
Transform complex XML documents into clean, structured JSON objects. Supports attributes and nested hierarchies with ease.
// Result will appear here...
Attributes
XML attributes are preserved and mapped using the @attributes prefix within the resulting JSON objects.
Array Logic
Multiple sibling elements with the same name are automatically grouped into clean JSON arrays.
Hierarchy
Deeply nested XML structures are recursively traversed to maintain data integrity and relationship.
About the XML to JSON Converter
Paste XML and get the same data as JSON, with attributes kept under "@attributes", repeated elements turned into arrays and the element hierarchy preserved.
Everything you enter is processed in your browser; nothing is uploaded or stored.
How to use it
- Paste your XML into Input XML.
- Read the JSON in JSON Result.
- Copy it into your JavaScript, API mock or config.
How XML maps to JSON
Each element becomes a key with its content as the value. Attributes go into an "@attributes" object on that element. When the same element appears several times under one parent, the values become an array.
The XML is read with the browser’s own XML parser, so badly formed XML (an unclosed tag, an unescaped &) is reported instead of being converted wrongly.
Example
<user role="admin"><name>John Doe</name></user> becomes {"user": {"@attributes": {"role": "admin"}, "name": "John Doe"}}.
Common mistakes
- Unescaped characters in text: & must be written & and < as < in XML.
- Expecting numbers and booleans: XML text is converted as strings, so "21" stays a string.
- Single vs repeated elements: one <item> gives an object, two give an array, so code reading the JSON should handle both.
Frequently asked questions
How are XML attributes converted?
They appear under "@attributes" on the element they belong to.
Can I convert JSON back to XML?
Yes, with the JSON to XML converter.
Is my XML uploaded?
No. It is converted in your browser.