XML formatter

Paste XML on the left, pick an indent, and click Format to pretty-print or Minify to flatten. Validation uses your browser's native DOMParser so any well-formedness error includes the line and column.

XML formatter

How it works

The formatter parses your XML with DOMParser, walks the resulting tree, and re-emits it with proper indentation. Comments, CDATA sections and processing instructions are preserved.

Common errors

  • Unclosed tags — every <tag> needs </tag> (or self-closing <tag/>).
  • Wrong nesting — <a><b></a></b> is invalid.
  • Unescaped &, <, > in text — use &amp;, &lt;, &gt;.
  • Multiple root elements — XML allows exactly one root.

FAQ

Does this validate against an XSD or DTD?

No — it only checks well-formedness (correct nesting, escaping, single root). Schema validation requires an XSD/DTD parser, which is a heavier dependency.

Does my XML leave the page?

No. Everything happens in your browser via DOMParser.

Related calculators