XML formatter

Paste XML to indent it neatly or minify it, and see at once whether it is well-formed.

Well-formed vs valid

Well-formed means the syntax is correct: one root element, every tag closed, properly nested, attribute values quoted, and special characters escaped. Valid additionally means the document matches a DTD or XML Schema. This tool checks well-formedness with the browser's DOMParser.

Common XML errors

ProblemExampleFix
Unescaped &<a>Q&A</a>Write &amp;
Mismatched tags<b><i></b></i>Close in reverse order
Two root elements<a/><b/>Wrap in one parent
Unquoted attribute<a id=1>id="1"

Frequently asked questions

Does formatting change the data?
Indentation adds whitespace between elements. That is harmless for data XML but can matter in mixed content such as XHTML paragraphs.
Can I format HTML with it?
Only XHTML. Regular HTML allows unclosed tags like <br> that are not well-formed XML.