XML validator

Check whether XML is well formed and get the line and column of the first error, such as an unclosed tag or a repeated attribute. Runs in your browser.

Processed locally in your browser
Loading tool…

About XML validator

The XML validator tells you whether a document is well formed: every tag closed and correctly nested, attribute values quoted and not repeated, and special characters in text escaped. Paste the XML or open a file and the result appears immediately, either “Valid XML” or an error message with the line and column where parsing failed.

Checking is done by the fast-xml-parser validator, running in a background worker in your browser. When the document passes, it is also shown indented so you can confirm its structure. Configuration files, feeds and payloads containing credentials can be checked without being sent to a server.

How to use XML validator

  1. Paste XML into the input box, or open or drop an .xml file.
  2. Look at the status bar: “Valid XML” means the document is well formed.
  3. If there is an error, go to the reported line and column and fix it in the input box; the check runs again as you edit.
  4. Optionally copy or download the indented output.

Features

  • Detects mismatched or unclosed tags, unquoted or repeated attributes, invalid tag names and unescaped & or < in text.
  • Reports the line and column of the first error with the parser’s message.
  • Requires an XML declaration, if present, to be at the very start of the document.
  • Accepts attributes written without a value, such as <option selected>, which strict XML parsers reject.
  • Shows valid documents indented with 2 spaces, 4 spaces or tabs.

Common uses

  • Finding why a sitemap or RSS feed is rejected by a search engine or feed reader.
  • Checking hand-edited files such as pom.xml, web.config or Android manifests before a build.
  • Confirming that XML generated by a template or script is well formed.
  • Debugging a SOAP request that a server refuses to parse.

Tips

  • An unescaped ampersand is the most common error in feeds and sitemaps. Write it as &amp; in text and in attribute values, including inside URLs. The validator catches a bare & in text, but is less strict inside attribute values, so check those by eye.

Frequently asked questions

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

Well-formed XML follows the basic syntax rules: matching tags, quoted attributes and escaped special characters. Valid XML is well formed and also conforms to a DTD or XML Schema. This tool checks well-formedness only; it does not load or apply schemas.

Why does an & in my text make the XML invalid?

In XML, & starts an entity reference such as &amp; or &lt;. A bare & in text, for example in “Fish & Chips”, is therefore an error. Replace it with &amp;, or wrap the text in a CDATA section.

Why is the error reported on a later line than the mistake?

A parser can only report an error where it notices one. An unclosed tag, for example, is usually detected when a different closing tag appears further down. If the reported line looks correct, look for an unclosed element above it.

Is the XML declaration required?

No. The <?xml version="1.0"?> line is optional for XML 1.0 documents in UTF-8, and the validator accepts documents with or without it. If it is present, it must be the very first thing in the file, with no spaces or blank lines before it.

Can it validate HTML?

Only XHTML written as well-formed XML. Ordinary HTML allows unclosed tags such as <br> and <li>, which XML treats as errors, so most web pages will fail. Use the HTML formatter for regular HTML.

Is my input uploaded?

Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.

Your privacy comes first

Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.

Find your next tool
↑ ↓ · Enter ↵Esc · Close search