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&,<,>. - 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.