XML Validator

Paste XML and it is checked as you type. Well-formed XML shows its root element. Broken XML shows the line and column where the parser stopped, and the line itself.

How it works

The check uses the XML parser built into your browser, the same one a web page uses to read an XML file. It is strict: one mistake and the parser stops.

When it stops, the tool reads the line and column out of the parser's message and shows that line of your XML, so you can find the problem without counting lines.

When the XML is well-formed, the tool tells you the name of the root element and how many elements the document holds. Your XML is checked on this page and is not uploaded.

How to use it

  1. 1 Paste your XML into the box, or type it.
  2. 2 Read the result under the box. It updates as you type.
  3. 3 If there is an error, go to the line and column shown, fix it, and watch the result turn to well-formed.

Good to know

  • The parser reports the first error only. Fix it and the next one, if there is one, appears.
  • The column is where the parser noticed the problem. The real mistake is often just before it, such as a quote that was never closed.
  • A bare & in text is the most common error in hand-written XML. Write it as &.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Finding the one broken tag in an XML file, and the errors that hide behind it

Start with a small file that works: <order> on the first line, <item>Tea</item> indented on the second, and </order> on the third. Paste it in and the result says the XML is well-formed, the root element is <order>, and the document has 2 elements. That count includes the root. Now make the kind of mistake that happens when you edit by hand: change the closing tag on line two to </itme>.

The result turns red. It says "Not well-formed" and gives line 2 and a column, with the parser's own message and a copy of line two underneath. The parser read <item>, then Tea, then a closing tag for an element called itme. Nothing called itme is open, so it stops there. The wording depends on your browser. Chrome says the opening and ending tags do not match, and Firefox says the tag is mismatched. Both point at line 2.

Fix the typo and the result goes back to well-formed. Then try a different mistake: change Tea to "Tea & milk". This looks harmless, but it is not well-formed. In XML, & starts an entity such as &amp; or &lt;, and a bare & followed by a space is not one. The parser stops on the &. Write "Tea &amp; milk" and the file is well-formed again. When a program reads it, it sees "Tea & milk". This is the most common error in XML written by hand or built by joining strings in code.

Some errors are reported later than they happen. Leave out the closing quote in <item sku="A1> and the parser keeps reading the attribute value, past the >, until it finds the next quote or reaches the end. The column it reports can be well after the real mistake. So when the reported spot looks fine, look a little earlier: an unclosed quote, an unclosed comment or a missing > before it are the usual causes. The parser also reports only the first error. Fix it, and the next one, if any, appears.

This tool has limits. It checks well-formedness, not validity. It does not read an XSD schema or a DTD, so a file with the wrong element names, or a missing required attribute, still passes. It uses the parser in your browser, so the exact message and sometimes the column differ between Chrome, Firefox and Safari, though they agree on whether a file is well-formed. And it checks one document at a time, as pasted. To also lay the file out, use the XML Formatter, which runs the same check first.

Frequently asked questions

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

Well-formed means the XML follows the syntax rules: every tag is closed, tags nest properly, attribute values are quoted, and there is exactly one root element. Valid means it also follows a schema or DTD that lists which elements and attributes are allowed. This tool checks well-formedness only.

Can it check my XML against an XSD schema?

No. Browsers do not include a schema validator, and this tool does not add one. It tells you whether any XML program can read the file, not whether the file has the right elements.

Why does the error point to the wrong place?

The parser reports where it noticed the problem, which can be after the real mistake. If an attribute quote is never closed, the parser reads on until something no longer makes sense, which may be a line or two later. Look at the reported line and the lines just before it.

Why does the error message read differently in another browser?

Chrome, Firefox and Safari each have their own XML parser and write their own messages. They agree on whether a document is well-formed, but the wording and sometimes the column differ.

Is my XML sent to a server?

No. Your browser's built-in parser checks it on this page. Nothing you paste leaves your device.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.