XML Formatter & XML ↔ JSON

Format XML, convert between XML and JSON. Beautify, minify, validate. Runs entirely in your browser.

XML Input
Formatted XML
Formatted output will appear here...

New tools every week

Get notified. No spam.

How to Convert Between XML and JSON

XML and JSON are the two dominant data interchange formats, but converting between them isn't always straightforward. XML has attributes, namespaces, mixed content, and ordering guarantees that JSON lacks. This XML converter handles the translation intelligently — attributes become @attr keys, text content becomes #text, and repeated elements become arrays.

The XML formatter beautifies or minifies XML documents with proper indentation, preserving the document structure. This is useful for reading SOAP responses, Maven POM files, SVG source, Android layouts, or any XML that's been minified for transport. The parser validates your XML and shows clear error messages when something's wrong.

Converting JSON to XML is useful when you need to send data to legacy SOAP APIs, generate XML configuration files programmatically, or create test fixtures. The converter handles the reverse mapping — arrays become repeated elements, @-prefixed keys become attributes, and nested objects become nested elements.

Tips

  • XML attributes are converted to @attributeName keys in JSON. When converting back, any JSON key starting with @ becomes an XML attribute.
  • Multiple child elements with the same name automatically become a JSON array. This matches the common XML pattern of repeated elements like <item>.
  • Use the formatter to debug XML parse errors — common issues include unclosed tags, mismatched tag names, and unescaped ampersands in text content.
  • When converting JSON to XML, the tool auto-detects single-key top-level objects and uses that key as the root element name.