How to use XML to JSON
- Paste the XML document.
- Decide whether to keep attributes, parse numbers/booleans and which elements must always be arrays.
- Copy or download the JSON.
XML to JSON features
- Well-formedness check with line and column for malformed XML
- Attributes preserved with the @_ prefix (or dropped on request)
- Repeated children become arrays; force arrays for specific element names
- Optional conversion of numeric and boolean text values
- CDATA content and entities decoded
- Summary of root element, element count and depth
XML to JSON example
Catalog with attributes and repeated elements
Input:
<catalog><product id="p-1"><name>Keyboard</name></product><product id="p-2"><name>Mouse</name></product></catalog>Output:
{
"catalog": {
"product": [
{ "name": "Keyboard", "@_id": "p-1" },
{ "name": "Mouse", "@_id": "p-2" }
]
}
}Frequently asked questions about XML to JSON
How are attributes represented?
Attributes become keys prefixed with @_ (e.g. "@_id"). If an element has both attributes and text, the text is stored under "#text". You can also drop attributes entirely.
Why is one element an object but another an array?
Repeated sibling elements are collected into an array; an element that occurs once stays an object. List element names under "Always-array elements" to force a consistent array shape.
Are numbers and booleans converted?
By default text such as 42, 3.5 and true is converted to JSON numbers and booleans. Disable "Parse numbers & booleans" to keep every value as a string (useful for zip codes and IDs with leading zeros).
What about CDATA, comments and namespaces?
CDATA content is included as text, comments and processing instructions are dropped, and namespaced names such as soap:Body are kept verbatim as keys.