XML to JSON Notes
- Text nodes become string values
- Attributes are preserved under @attributes key
- Repeated tags become arrays
- All processing runs in your browser
Convert XML to JSON for use in modern JavaScript, REST APIs, and document stores. The converter parses the XML with the browser’s DOMParser, then walks the tree: each element becomes an object keyed by its tag name, attributes become @-prefixed properties, and repeated child elements collapse into JSON arrays.
When an element has both attributes and text content, the text lives under #text alongside the @-prefixed attribute keys (the standard convention used by libraries like xml2js). Output can be pretty-printed for readability or minified to save bytes. Useful for migrating SOAP/RSS feeds into JSON-based pipelines without writing custom parsing code.
Two or more siblings with the same name become a JSON array; a single child remains a plain key. Force-array mode keeps every child as an array even when there’s only one — useful when downstream code expects consistent shapes.
Each attribute becomes a key prefixed with @ (e.g. {"@id": "3"}). When an element has both attributes and text content, the text lives under the #text key alongside the attribute entries.
By default the prefix is included in the key (e.g. "ns:tag"). You can choose to strip namespace prefixes if your downstream consumer doesn’t need them.
No — parsing uses the browser’s built-in DOMParser and the conversion is local JavaScript.
Explore the full suite of DEVELOPER tools and 290+ other free utilities at Chunky Munster.