How to validate XML
- Paste XML, open a file or load it from a URL. The document is checked automatically as you type.
- Read the error message: it names the problem and gives its line and column. Click Validate to jump straight to it.
- Fix the line. When the result shows Well-formed XML, you can format, minify, copy or download the document.
Common XML errors and how to fix them
| Error | Wrong | Right |
|---|---|---|
| Closing tag does not match | <b><i>text</b></i> | <b><i>text</i></b> |
| Element never closed | <item>Pen | <item>Pen</item> |
| Names differ in case | <Item>…</item> | <Item>…</Item> |
| Unescaped ampersand | Tom & Jerry | Tom & Jerry |
| Unescaped less-than sign | a < b | a < b |
| Attribute without quotes | <p id=5> | <p id="5"> |
| Duplicate attribute | <p id="1" id="2"> | <p id="1"> |
| More than one root element | <a/><b/> | <root><a/><b/></root> |
| HTML entity | |   |
| Declaration not at the start | A blank line before <?xml …?> | <?xml …?> as the very first characters |
| Double hyphen in a comment | <!-- a -- b --> | <!-- a - b --> |
Well-formed vs. valid XML
A well-formed document follows the syntax rules of the XML 1.0 specification: one root element, properly nested and closed tags, quoted attribute values and escaped special characters. Every XML parser rejects a document that is not well-formed.
A valid document is well-formed and also matches a schema – a DTD or an XSD that defines which elements and attributes are allowed. This page checks well-formedness. To validate against a schema, use a schema-aware tool, for example xmllint --noout --schema schema.xsd file.xml.
Frequently asked questions
Does this validate XML against an XSD or DTD?
No. It checks well-formedness, the syntax that every XML parser requires. A DOCTYPE is allowed in the document, but the XML is not compared with a DTD or XSD schema.
Why is only one error shown?
The XML specification treats every well-formedness error as fatal, and one mistake – such as a missing closing tag – often causes misleading errors further down. Fix the first error and the rest of the document is checked immediately.
Can I check sitemaps, RSS feeds or SVG files?
Yes. Any XML-based format can be checked for well-formedness. For sitemaps, the Sitemap validator additionally checks the sitemap protocol rules.
Is my XML uploaded?
No. Validation runs in your browser. Only a URL you load is fetched through our server.