Home/Text & Encoding/XML ↔ JSON
Back to tools

XML ↔ JSON Converter

Convert between XML and JSON formats with attribute preservation and proper formatting

Examples:

About XML and JSON

  • XML (eXtensible Markup Language) uses tags to define elements and supports attributes
  • JSON (JavaScript Object Notation) uses key-value pairs and arrays for data structure
  • • XML is more verbose but supports namespaces, schemas, and validation
  • • JSON is more compact and directly usable in JavaScript
  • • Both formats are widely used for data exchange and APIs

Conversion Notes:

  • • XML attributes are prefixed with "@_" in JSON when preserved
  • • Text content is stored as "#text" in JSON
  • • XML comments and processing instructions may be lost
  • • Arrays in JSON become repeated elements in XML
  • • Some data type information may change during conversion

Special Characters:

  • • XML entities (<, >, &, ", ') are properly handled
  • • Unicode characters are preserved in both formats
  • • CDATA sections in XML are converted to text in JSON