XML to JSON
Convert an XML document into a JSON value. Paste XML on the left; the JSON output builds on the right as you type.
<order id="1042">
<status>shipped</status>
<items>pen</items>
<items>notebook</items>
</order>
becomes
{
"order": {
"@_id": "1042",
"status": "shipped",
"items": ["pen", "notebook"]
}
}
The root element’s tag name becomes the single top-level key. id="1042" becomes @_id because it’s an attribute, not a child element. The two <items> elements share a name, so they collapse into one items array rather than overwriting each other.
Attributes and text together
An element that mixes attributes with text content, like <price currency="usd">19.99</price>, needs both an @_currency key and a #text key: { "price": { "@_currency": "usd", "#text": "19.99" } }. An element with only text and no attributes, like <name>Ada</name>, skips the wrapper entirely and becomes "name": "Ada".
Values stay text
XML doesn’t distinguish a number from a string; <count>3</count> and <count>three</count> are both just element text. This converter keeps every XML value as a JSON string rather than guessing which ones should become numbers or booleans, so a downstream JSON.parse on a numeric field needs an explicit conversion.
Malformed XML
An unclosed tag, a stray & that isn’t part of a named entity like &, or more than one element at the root all fail to parse. The input pane’s error footer reports the line and column the parser stopped at, taken directly from the browser’s XML parser.