XML to JSON
Convert XML to JSON
Frequently Asked Questions
How does XML to JSON conversion work?
XML elements become JSON objects, text content becomes string values, attributes become properties with @ prefix, and repeated elements become arrays. <name>Alice</name> becomes {"name":"Alice"}.
How are XML attributes converted?
Attributes are prefixed with @ by default: <item id="1">text</item> becomes {"item":{"@id":"1","#text":"text"}}. You can customize the attribute prefix or merge attributes with child elements.
How are repeated XML elements handled?
Repeated elements automatically become JSON arrays: <items><item>A</item><item>B</item></items> becomes {"items":{"item":["A","B"]}}. Single elements remain as values unless you force array mode.
What happens to XML comments and CDATA?
Comments are stripped by default (optional to preserve). CDATA sections are converted to plain text strings. Processing instructions are removed. The converter focuses on data content, not XML-specific markup.
Can I customize the conversion rules?
Yes. Configure attribute prefix (@ or custom), text node key (#text or custom), array handling (force arrays for specific elements), and namespace handling (strip, preserve, or prefix). These options handle most XML-to-JSON mapping needs.