XML to JSON Converter
Convert XML to JSON with control over the mapping: attribute prefix, text key, and whether repeated elements always become arrays. See exactly how elements, attributes and text end up in JSON.
How XML maps to JSON (and why shapes jump)
XML has attributes, mixed text and repeated elements; JSON has only objects, arrays and values. Every converter has to choose. Toggle each feature to see the choice.
<library> <book id="42" lang="en"><title>Dune</title></book> </library>
{
"library": {
"book": {
"title": "Dune",
"@_id": 42,
"@_lang": "en"
}
}
}- Attributes become keys with an
@_prefix so they cannot collide with child elements of the same name.
How it works
XML has things JSON lacks (attributes, mixed text, ordered repeated elements), so every converter makes choices. Attributes get a prefix (default @_), text inside an element with attributes goes to #text.
A single child becomes an object, repeated children become an array. "Always arrays" keeps the shape stable when the count varies between documents.
Everything above runs in JavaScript inside this tab. Your data is not uploaded. Inputs are remembered in this browser only so they survive a reload; you can switch that off on the privacy page.
Questions
Why is one item an object but two items an array?
The converter sees one <item> and cannot know more may appear. Enable "always use arrays for repeated elements" so the shape is consistent.
Are namespaces kept?
Prefixes stay in the key names (soap:Envelope). Namespace declarations appear as attributes.
Is my XML sent to a server?
No. Conversion happens in your browser. The only network request is the optional AI explanation when your input has an error and you ask for it.