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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Ctrl+Enter to validate

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 &amp;, &lt;, and &gt; when used in text content.

<title>A & B</title>       <!-- invalid -->
<title>A &amp; 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

InputWhy it is not well-formed
<a/><b/>Two root elements. A document has exactly one.
<a/>trailingText outside the root element.
<a>Tom & Jerry</a>A raw ampersand: write &amp; 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.

Frequently Asked Questions

What is the difference between well-formed and valid XML?
Well-formed XML follows basic syntax rules: proper nesting, matched tags, quoted attributes, and a single root element. Valid XML goes further. It also conforms to a specific schema (DTD, XSD, or RelaxNG) that defines which elements and attributes are allowed. All valid XML is well-formed, but not all well-formed XML is valid against a particular schema.
What is the difference between XML and HTML?
XML is stricter than HTML. In XML, all tags must be closed, tag names are case-sensitive, attribute values must be quoted, and there are no predefined elements. HTML is more forgiving: browsers can render HTML with unclosed tags and unquoted attributes. XML is designed for data transport, HTML for display.
Why does my XML parser fail on special characters?
XML reserves certain characters for its syntax: < (less than), > (greater than), & (ampersand), ' (single quote), and " (double quote). When these characters appear in text content or attribute values, they must be replaced with XML entities: &lt;, &gt;, &amp;, &apos;, and &quot; respectively.
Is this XML validator free to use?
Yes, our XML validator is completely free with no limits on usage. No registration or account required. Paste your XML, validate it, and get detailed error reports as many times as you need.
Can I validate XML against an XSD schema?
No. This validator checks well-formedness, the syntax rules every XML document must follow before any schema can be applied. To validate against an XSD, run xmllint --schema schema.xsd file.xml (part of libxml2) or use your editor's XML tooling.
Why is XML case-sensitive but HTML is not?
XML was designed to be strict and unambiguous for machine-to-machine data exchange. Case sensitivity eliminates ambiguity: <Name> and <name> are different elements in XML. HTML was designed for human authoring with browser tolerance, so browsers treat <DIV> and <div> as the same element.
How do I handle namespaces in XML?
XML namespaces prevent element name conflicts when combining documents from different sources. They are declared using xmlns attributes with a URI prefix. For example: <book xmlns:isbn="urn:isbn"> lets you use <isbn:number> without conflicting with other elements named 'number'. Our validator checks that namespace declarations are well-formed.

Related Tools