XML to JSON
Recursively convert an XML element tree into a simple JSON object keyed by tag names.
How to use
- Enter XML and run to inspect the JSON structure.
Capabilities and scope
Leaf elements become textContent and repeated sibling tag names are promoted into arrays.
How it works
After DOMParser validation, child elements are recursively converted; a repeated key changes from one value to an array.
Example
<root><item>A</item><item>B</item></root> produces an item array.
Useful for
- Quickly map simple element-oriented XML into JSON
Before you use it
- Attributes, namespaces, mixed-content order, and other XML metadata are not preserved, so information can be lost.
Frequently asked questions
Are XML attributes included?
No. The current conversion focuses on element children and textContent.