XML to JSON Converter Online
How XML Constructs Map to JSON Objects and Arrays
Converting documents from the W3C XML 1.0 standard into RFC 8259 JSON requires resolving structural differences between hierarchical tree markup and key-value objects. XML elements can carry attributes, namespace prefixes, and inner text simultaneously, whereas JSON separates data strictly into objects, arrays, strings, numbers, booleans, and null values.
Use the toolbar above to match the exact mapping convention your application expects, whether that is Fast-XML @_ attribute prefixes, BadgerFish @ and $t keys, or stripped SOAP namespaces. Switch to the Tree Explorer tab to filter nested keys and copy exact $.path selectors in one click. If you need to indent, validate, or minify raw XML markup before converting, inspect it with our XML beautifier.
XML to JSON Mapping Reference
How the converter translates XML attributes, repeated sibling tags, namespaces, and data types into JSON.
| XML Construct | XML Markup Example | Converted JSON Behavior |
|---|---|---|
| Element with attributes & text | <price currency="USD">149.50</price> | Maps attributes with the selected prefix ("@_currency": "USD") and assigns inner text to the text node key ("#text": 149.5). |
| Repeated vs single child tags | <items><item>A</item><item>B</item></items> | Auto mode groups repeated sibling tags into a JSON array (["A", "B"]). Always array mode wraps single child elements in an array too. |
| SOAP & XML namespaces | <soap:Envelope xmlns:soap="..."> | Retains prefixed tag names by default, or strips xmlns declarations and prefixes ("Envelope") when Strip namespace prefixes is active. |
| Leading zeros & 64-bit IDs | <postalCode>02138</postalCode> | Keeps strings with leading zeros ("02138") and 16+ digit IDs as strings so postal codes and snowflake IDs never lose precision. |
| CDATA sections & entities | <note><![CDATA[A < B & C]]></note> | Unwraps CDATA blocks and decodes XML entities (&, <) into clean RFC 8259 escaped JSON strings. |