Skip to content
YouNeed Tools
Free VPN

XML Formatter and Validator

Paste XML or open a file. It is checked for well-formedness and pretty-printed or minified as you type, with any error shown by line and column.

Output
Indent

Well-formed. Root element <catalog>, 9 elements.

Formatted on your device. Nothing you paste is sent anywhere.

Worked example

This one-line message <note><to>Tove</to><from>Jani</from><body>Don’t forget me this weekend!</body></note> becomes:

<note>
  <to>Tove</to>
  <from>Jani</from>
  <body>Don’t forget me this weekend!</body>
</note>

If the closing tag is mistyped, <to>Tove</from>, the checker stops with: line 2, column 11: Expected </to> (opened on line 2) but found </from>.

The errors people hit most

XMLProblemMessage
<a><b></a></b>Tags closed in the wrong orderExpected </b> (opened on line 1) but found </a>.
<item id=5/>Attribute value without quotesThe value of “id” must be in quotes.
<p>Fish & chips</p>A bare & in textA bare “&” must be written as &amp; (or start an entity like &lt;).
<a x="1" x="2"/>The same attribute twiceAttribute “x” appears twice in <a>.
<a/><b/>Two root elementsA second root element <b>. An XML document has exactly one root element.

XML rules in brief

  • Names are case-sensitive: <Item> and <item> are different elements.
  • Names can’t start with a digit, a hyphen or a dot, and can’t contain spaces.
  • Empty elements can be written <br/> or <br></br>.
  • Only five entities are built in: &amp; &lt; &gt; &quot; &apos;. Others, like &nbsp;, need a DTD; use the number form &#160; instead.
  • The <?xml version="1.0"?> declaration is optional, but if present it must be the very first thing in the file.

Related tools

Sources

Checked on November 26, 2026:

Frequently asked questions

What does “well-formed” mean?
That the XML follows the basic syntax rules: exactly one root element, every tag closed and properly nested, attribute values in quotes, no repeated attributes, valid names and & used only for entities like &. Any XML parser must reject a document that breaks these rules.
Is this a schema validator?
No. It checks well-formedness, not whether the elements match a DTD or XML Schema (XSD). A document can be well-formed and still be invalid for a particular format.
Why does my file fail on an ampersand?
In XML, & starts an entity. Write it as & in text and attribute values, or wrap the text in a CDATA section, .
Can it format SVG, RSS and sitemap files?
Yes. They are all XML. Open the file or paste it in; CDATA, comments and processing instructions are kept as they are.
Does pretty printing change the data?
It removes whitespace-only text between tags and adds indentation. For most data formats that is harmless, but where whitespace inside mixed content matters (such as xml:space="preserve"), compare the output before using it.
Is my XML uploaded?
No. It is checked and formatted on your device, which matters for configuration files with keys and passwords.

Last updated: 2026-11-26