Free XML Validator
Paste your XML code to check for syntax errors, unclosed tags, and well-formedness issues. Get a quality score with detailed error reports.
Valid but unreadable? The XML Formatter indents or minifies it in your browser, without touching text, attributes or CDATA.
Well-Formedness Check
Verify that your XML follows all well-formedness rules: proper nesting, matched tags, correct attribute syntax, and valid character encoding.
Error Pinpointing
Get exact line and column numbers for every issue. Quickly jump to the problem and fix it without hunting through your code.
Quality Score
Get a 0-100 score and letter grade for your XML quality. Track improvements as you fix issues in your documents.
What Is XML Validation?
XML (Extensible Markup Language) is a markup language designed to store and transport structured data. Unlike HTML, XML has no predefined tags. You define your own elements and structure, which makes strict validation essential.
XML validation has two levels. The first is well-formedness: the document must follow XML syntax rules such as proper tag nesting, matched opening and closing tags, quoted attribute values, and correct use of special characters. A document that breaks any of these rules is not valid XML and cannot be parsed.
The second level is schema validation, which checks whether the document conforms to a specific structure defined by a DTD, XML Schema (XSD), or RelaxNG schema. Our validator focuses on well-formedness, the foundation that every XML document must satisfy before any schema validation can occur.
Common XML Errors
Unclosed Tags
Every opening tag must have a corresponding closing tag. Unlike HTML, XML does not auto-close tags.
<name>John <!-- invalid --> <name>John</name> <!-- valid -->How to fix unclosed tags →
Mismatched Tags
Opening and closing tags must match exactly, including case. <Name> cannot be closed with </name>.
<Name>John</name> <!-- invalid --> <Name>John</Name> <!-- valid -->How to fix mismatched tags →
Unquoted Attributes
All attribute values must be enclosed in quotes (single or double). Unquoted values are a syntax error.
<book id=1> <!-- invalid --> <book id="1"> <!-- valid -->How to fix unquoted attributes →
Unescaped Special Characters
Characters like &, <, and > must be escaped as &, <, and > when used in text content.
<title>A & B</title> <!-- invalid --> <title>A & B</title> <!-- valid -->How to fix unescaped special characters →
Improper Nesting
Tags must be properly nested. You cannot close a parent tag before closing its children.
<a><b></a></b> <!-- invalid --> <a><b></b></a> <!-- valid -->
Multiple Root Elements
An XML document must have exactly one root element. Multiple root elements make the document invalid.
<a/><b/> <!-- invalid --> <root><a/><b/></root> <!-- valid -->How to fix multiple root elements →
Invalid XML Declaration
The declaration must be the very first thing in the file, with no whitespace or comment before it, and its attributes come in a fixed order.
<!-- hi --> <?xml version="1.0"?> <!-- invalid --> <?xml version="1.0"?> <!-- valid, first line -->How to fix invalid xml declaration →
Browse every XML error guide for the rest, each with the wrong and right version side by side.
XML Errors This Validator Catches
| Input | Why it is not well-formed |
|---|---|
| <a/><b/> | Two root elements. A document has exactly one. |
| <a/>trailing | Text outside the root element. |
| <a>Tom & Jerry</a> | A raw ampersand: write & instead. |
| <a id="1" id="2"/> | The same attribute twice on one element. |
| <a><b></a></b> | Elements closed in the wrong order. |
| <a><b></b> | An element that is never closed. |
| <1a/> | A name cannot start with a digit. |
Like browsers and xmllint, it stops at the first fatal error and gives its line and column: after a well-formedness error the rest of the document cannot be read reliably, so listing more would mostly list consequences. Documents that are valid must stay valid too: namespaces, a DOCTYPE with an internal subset, comments and processing instructions around the root, CDATA and a byte-order mark are all in the test suite, along with real RSS feeds and sitemaps.
Checking a Sitemap or an RSS Feed
A sitemap or a feed that is not well-formed is rejected as a whole, which is why this is the first check to run. Paste the file to find the exact line, usually an unescaped & in a URL or a title.
Well-formed is not the same as correct for its format: this validator does not check the sitemap protocol itself, such as its limit of 50,000 URLs per file or that every <loc> is an absolute URL, nor the RSS or Atom rules. It tells you the file can be parsed, which is what every one of those checks needs first. The XML error guides explain each failure, for example an unclosed tag.