XML ↔ JSON Converter ⚡

Convert XML to JSON and back. Handles attributes and namespaces.

Input
Error
Output
Error

Converting Between XML and JSON

XML (eXtensible Markup Language) and JSON (JavaScript Object Notation) are two widely used formats for structuring and transmitting data. While JSON has become the standard for modern web APIs due to its lighter weight and easier integration with JavaScript, XML remains heavily used in enterprise systems, RSS feeds, and legacy APIs.

How We Handle Attributes and Namespaces

Because XML supports features like attributes and namespaces that JSON does not natively have, we use a standard conversion convention:

  • Attributes: XML attributes are converted to JSON properties prefixed with @ (e.g., <item id="1"> becomes {"@id": "1"}).
  • Text Content: If an XML element has both attributes and text content, the text content is stored under a special property named #text.
  • Namespaces: Namespaces are preserved in element names (e.g., <soap:Envelope> becomes {"soap:Envelope": ...}) and as attributes if they are defined on the element.
  • Multiple Children: If an XML element has multiple child elements with the same name, they are automatically grouped into a JSON array.

Browser-Based and Secure

This conversion tool runs entirely within your web browser using JavaScript's native DOMParser and object serialization. Your data is never uploaded to any server. You can even use this tool offline after the page has initially loaded.