XML to JSON
Convert XML to a JSON object using recursive element traversal.
$xml input
0 chars1 lines
$json output[READY]
0 chars1 lines
Related Tools
FAQ
- How are XML attributes represented?
- Attributes are stored under an @attributes key as a nested object. For example, <item id="1"> becomes {"@attributes":{"id":"1"}}.
- What happens with repeated child elements?
- When multiple child elements share the same tag name, they are collected into an array under that key, mirroring the XML structure.
- Is the namespace prefix preserved?
- Yes. Namespace-prefixed element names such as soap:Body are preserved as-is in the resulting JSON keys.
XML to JSON parses XML using the browser's built-in DOMParser and converts it to a JSON object recursively. Element attributes are mapped to @attributes keys, text content to #text, and child elements to nested objects. Multiple children with the same tag name become arrays. Useful for working with SOAP APIs, RSS feeds, and legacy XML data sources.