XML Validator

Paste XML or open a file and press Validate XML. Errors are shown with their line and column and a pointer to the problem; valid XML can be formatted or minified, with an outline of its elements.

Try an example
The file is read in your browser and placed in the box.

About this XML validator

Well-formed XML follows a short list of strict rules: there is exactly one root element, every opening tag has a matching closing tag in the right order, attribute values are quoted and not repeated, and the characters < and & are written as &lt; and &amp; in text. Unlike HTML, a single mistake makes the whole document unreadable to XML parsers, which is why feeds, sitemaps, and config files break so easily. This validator reads your XML with those rules, stops at the first problem, and points to its line and column with a plain explanation. It checks syntax only; it does not validate against a DTD or XML Schema.

How to validate XML

  1. Add your XML. Paste XML, open a file such as a sitemap, feed, or config, or press an example.
  2. Choose what to do. Validate only, or also format the XML with indentation or minify it to a single line.
  3. Press Validate XML. Fix any error at the line and column shown, then press again. Valid XML shows its counts and an outline you can expand.

Frequently asked questions

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

Well-formed XML follows the basic syntax rules, which is what this tool checks. Valid XML is also checked against a DTD or XML Schema that defines which elements are allowed, which needs the schema file and a schema-aware parser.

Why is a plain & an error?

In XML the ampersand starts an entity such as &amp; or &lt;. A lone & in text, as in News & Updates, must be written as &amp; or the document is not well-formed.

Why is &nbsp; not allowed?

XML only knows five named entities: &amp;, &lt;, &gt;, &quot;, and &apos;. HTML names such as &nbsp; need a DTD, so use the numeric form &#160; instead.

Can a document have more than one root element?

No. Everything must sit inside one top-level element. Wrap several elements in a parent, such as <items>…</items>, to fix the error.

Does formatting change my data?

Formatting only changes the whitespace between tags, plus how special characters are escaped. Text inside elements that hold only text is trimmed at the ends, and comments and CDATA sections are kept.