XML to JSON Converter
Example
Input:
<person><name>Ali</name><age>30</age></person>
Output:
{
"person": {
"name": "Ali",
"age": 30
}
}About this converter
This converter parses the XML with a real parser (not regex) and maps it to JSON by the standard conventions: an element with no attributes and no children becomes its text value, with obvious numbers and booleans typed; attributes are preserved as @name keys so nothing is lost; siblings sharing a tag collapse into an array under that tag; mixed content keeps its text under #text. Those conventions make the output predictable and round-trippable with this site's JSON to XML converter. Namespaces are kept literally in tag names (prefix:local), because stripping them silently is how data pipelines lose meaning.
Frequently Asked Questions
Why did a single child not become an array?
One occurrence cannot be distinguished from a lone element; arrays form from two or more same-tag siblings — the universal ambiguity of XML-to-JSON mapping.
What happens to comments and the XML declaration?
They are structural noise for data purposes and are dropped; the root element becomes the top-level key.