Skip to content

XML Validator

This XML validator checks that your XML is well-formed and shows each error with its line, column, the code around it and a suggested fix.

Input · XML

Invalid XML

Line 11, column 3

</line> does not match <lines>.

 9      <price>3.20</price>10    </line>11  </line>    ^12</invoice>

Fix: Close <lines> first. Tags must close in the reverse order they opened.

Also see line 7, column 3: <lines> opened here.

Invalid XMLRuns in your browser

Load from a URL

Your browser fetches it directly, so the server must allow cross-origin requests (CORS).

How to validate XML

  1. Paste the XML or open the file. It is checked as you type; Validate (Ctrl + Enter) opens the Report tab.
  2. A broken document shows the line and column, the code around it with a caret, and a Fix: line. Go to error jumps there.
  3. Once it passes, Format re-indents it. The XML formatter adds Self-close empty tags.

What the XML validator reports

You wrote The validator says
<item>Tea</itme> </itme> does not match <item>. and the line where <item> opened
?id=7&ref=feed in a link Unescaped '&'. with the fix &amp;
&nbsp; Unknown entity &nbsp; with the fix &#160;
two elements at the top level Second root element <user>.
<book id=42> Value of id must be in quotes.
<!-- old -- do not use --> '--' is not allowed inside a comment.
a blank line before <?xml The XML declaration must be the very first thing in the document.

A tag left open to the end gets <catalog> is never closed., with a pointer to where it opened.

Well-formed, not schema-valid

The check covers the XML 1.0 rules every parser enforces: one root element, tags closed in reverse order, quoted attributes, & and < escaped in text. It does not validate against an XSD or DTD, so a missing required element or a non-numeric <qty> passes. Entities declared in the document’s own DOCTYPE are understood; external DTD files are not loaded.

For schema validation in a script or CI job, use xmllint from libxml2:

xmllint --noout --schema invoice.xsd invoice.xml

Java’s “Content is not allowed in prolog”

Java’s XML parser throws this when text comes before the root element, often a JSON or plain-text error body where XML was expected. Paste the response here to see what precedes the first tag, or read Content is not allowed in prolog.

Valid XML can go on to the XPath tester or XML to JSON.

Questions

Does it list every error at once?

No. After a well-formedness error a parser cannot trust what follows, so the report shows the first problem and updates as you fix it.

Is this the same check as xmllint?

It covers what xmllint --noout file.xml checks, whether the file is well-formed, with messages that name the tag or attribute and say how to fix it.

Why does HTML that browsers accept fail here?

HTML allows tags that are never closed, attributes without quotes or values, and entities such as nbsp. XML allows none of these, so write the document as XHTML.

Is the file uploaded?

No. The XML is parsed in this tab, so invoices, SOAP payloads and configs with credentials stay on your machine.

Related tools

Esc