Tools

XML → JSON

Convert XML data to JSON format.

XML
Ln:1 Col:1
JSON

About XML to JSON Conversion

XML (Extensible Markup Language) has been a foundational data interchange format for decades, powering SOAP web services, enterprise integrations, RSS feeds, and configuration files. Converting XML to JSON is essential when modernizing legacy systems, integrating with REST APIs, or migrating data between platforms. This tool parses XML elements, attributes, and text content into a clean JSON structure.

XML to JSON Mapping Rules

XML elements become JSON object keys. Attributes are prefixed with @ (e.g., @id, @class). Text content in mixed elements uses the #text key. Repeated child elements with the same tag name are automatically converted to JSON arrays. Self-closing tags like <br/> produce empty strings or objects with only attributes.

Key considerations: XML has no native array type — repeated siblings are detected and grouped. XML attributes have no direct JSON equivalent, so the @ prefix convention is widely used. XML namespaces, processing instructions, and comments are stripped during conversion. CDATA sections are treated as plain text content.

Frequently Asked Questions

How are XML attributes handled in JSON?
Attributes are converted with an @ prefix. For example, <link url="..."> becomes {"@url": "..."}. This convention is commonly used by xml2json libraries.
How are repeated XML elements handled?
When multiple sibling elements share the same tag name, they are automatically grouped into a JSON array. A single element remains a plain object.
Are XML namespaces supported?
Namespace prefixes are preserved in tag and attribute names (e.g., "ns:element"), but namespace declarations (xmlns) are treated as regular attributes.