Home › File & PDF Tools › XML Validator

XML Validator

Use this free XML validator to check whether your XML is well-formed. Paste your XML into the box, press Validate, and the tool tells you instantly whether it is valid — along with the root element name and element count — or shows the first error it found, with its line and column when the parser reports them. You can also pretty-print valid XML with one click.

Paste XML and press Validate
Nothing checked yet.

How it works

XML, or Extensible Markup Language, is a way of storing structured data in plain text with tags, the same angle-bracket style used in HTML. A configuration file, a sitemap, an RSS feed, and a data export can all be XML. For any program to read that data, the document must be well-formed: it needs exactly one root element, every opening tag needs a matching closing tag with the same spelling and case, attribute values must sit inside quotes, and characters like < and & inside text must be written as entities (&lt; and &amp;).

This validator uses the XML parser built into your browser. When you press Validate, it reads your text and tries to parse it as an XML document. If the parse succeeds, the tool reports VALID, names the root element — the single outermost tag — and counts every element in the document, including nested ones. If the parse fails, it reports INVALID and shows the parser's own error message, which usually names the problem and gives a line and column number so you can jump straight to the faulty spot.

Well-formed = one root element + matched tags + quoted attributes + escaped special characters

The Format button takes valid XML and re-indents it, two spaces per level, so nested elements line up and the structure is easy to read. It works on the same parse as the validator, so if the XML is invalid, formatting is refused and the error is shown instead — pretty-printing broken XML would only hide the problem. Use the Load sample button to see a small valid document, or to test the tool before pasting your own file.

Common errors are easy to spot once you know the pattern. A closing tag spelled differently from its opening tag — <item> closed by </itm> — is the most frequent one, and case matters: <Item> and </item> do not match. An & in ordinary text, such as "fish & chips", must be written as &amp;. A document with two root elements, or with text sitting outside the root element, fails too. And a tag opened inside another tag must close before its parent does: <a><b></a></b> is wrong, while <a><b></b></a> is right.

Well-formed is not the same as valid in the strictest sense. A document can be well-formed — correct syntax — yet still break a schema or DTD that defines which elements and attributes are allowed. This tool checks the syntax layer, which is the step that catches most real-world breakage in feeds, sitemaps, and configuration files. If your XML passes here and still fails in another program, the next place to look is that program's schema or its namespace requirements.

Worked example

Try the sample document: <note> containing <to>Alex</to> and <message>Hello</message>.

Step 1: Press Load sample, then Validate.
Step 2: The result is VALID — root element note, with 3 elements in total (note, to, and message).
Step 3: Press Format, and the document is re-indented with two spaces per level.
Step 4: Now delete the closing </message> tag and press Validate again — the result changes to INVALID, with an error about the unclosed tag and the line where the parser noticed it.

FAQ

What makes an XML file invalid?

The most common causes are a mismatched or missing closing tag, an unescaped & or < inside text, a bad attribute quote, or more than one root element. This validator reports the first error it finds, with its line and column when the browser reports them.

What is the difference between well-formed and valid XML?

Well-formed XML follows the basic syntax rules: one root element, matched tags, quoted attributes. Valid XML also matches a schema or DTD. This tool checks that your XML is well-formed, which is the first step before any schema check.

Does this XML validator upload my data?

No. Everything runs in your browser — your XML is never sent to a server, so you can safely check private configuration files and data exports.

How do I fix an unclosed tag error?

Find the line the error message points to, check that every opening tag has a matching closing tag with the same spelling and case, and remember that empty elements need a self-closing form such as .