How This Tool Converts XML to JSON
- The root XML element becomes the top-level key in the JSON output. Child elements become nested JSON object properties, preserving the original structure.
- XML attributes are placed in an
@attributesobject inside the element's JSON representation — for example,<user id="1">becomes{ "user": { "@attributes": { "id": "1" } } }. - Repeated sibling elements sharing the same tag name are automatically collapsed into a JSON array — three
<role>elements become"role": ["admin", "editor", "viewer"]. - Text-only elements become string values. When an element contains both text and child elements, the text is placed under a
#textkey alongside the child element keys.
When to Use XML to JSON
- When consuming a SOAP or legacy REST API that returns XML and you need to process the response with a JSON-native tool or language.
- When migrating data from an XML-based system (RSS feeds, sitemap files, legacy exports) into a JSON API or database.
- When you receive an XML configuration file and want to inspect or query it with JSONPath or
jq. - When integrating with third-party services that return XML and your application only handles JSON payloads.
Frequently Asked Questions
How are XML attributes handled in the JSON output?
XML attributes are placed in an @attributes object inside the element's JSON representation. For example, <user id="1"> becomes { "user": { "@attributes": { "id": "1" } } }.
How are repeated XML elements converted?
Repeated sibling elements with the same tag name are automatically converted to a JSON array. Three <role> elements become "role": ["admin", "editor", "viewer"].
Is my XML data sent to a server?
No. All conversion happens entirely in your browser. Your data never leaves your device.
What happens when an XML element has both text and child elements?
When an element contains both text content and child elements, the text is placed under a #text key alongside the other child keys. For example, <item>Note: <name>Alice</name></item> becomes { "item": { "#text": "Note: ", "name": "Alice" } }.
Can this tool convert SOAP XML?
Yes. SOAP envelopes convert to nested JSON objects. Namespace prefixes such as soapenv: or ns: are preserved as part of the key names in the output — <soapenv:Envelope> becomes a key named soapenv:Envelope in the JSON.