XML Validator
Check XML for syntax errors and well-formedness.
XML Validator Online
The XML validator checks whether a document is well-formed and tells you exactly where it is not. Paste XML or open a file: a valid document gets a green confirmation with element, attribute, comment, and depth statistics plus a neatly formatted copy; a broken one gets an error with the line and column of the problem.
Well-formed vs. schema-valid
XML has two levels of correctness, and it is worth knowing which one you need:
- Well-formed means the document follows the XML syntax rules: exactly one root element, every opening tag closed in the right order, attribute values in quotes, no duplicate attributes, and
<and&escaped in text. Any XML parser will refuse a document that fails these rules. This is what this tool checks. - Schema-valid means the document also matches a contract — an XSD, DTD, or RELAX NG schema that says which elements are allowed, in what order, and with which data types. A document can be perfectly well-formed and still fail a schema, for example when a required
<price>element is missing.
Well-formedness comes first: a schema validator cannot even start on a document that does not parse.
Try an invalid sample
Load the sample, then break it: delete a </title> tag, or replace & with a bare &. The validator immediately reports the mismatch, including the line where the unclosed element began, which makes it easy to track down errors in long generated files.
Where it helps
Checking hand-edited configuration files before a deploy, verifying the output of a template engine, debugging a feed that a reader refuses to load, or confirming that a SOAP body is intact after copying it from logs.
Related tools
Explore the structure in the XML Viewer, fix formatting in the XML Editor, or validate other formats with the JSON Validator and YAML Validator.
Frequently Asked Questions
Does this validate against an XSD or DTD schema?
No. The validator checks that the document is well-formed — correct nesting, matching tags, quoted attributes, escaped special characters, a single root element. It does not check element names or data types against an XSD, DTD, or RELAX NG schema.
What are the most common XML errors?
A closing tag that does not match the open element, an unescaped & in text (write &), an attribute value without quotes, two top-level elements instead of one root, and text or whitespace before the <?xml?> declaration.
Why does the error point to a line after the real mistake?
The parser reports where it noticed the problem. An element left open on line 3 is only detected when a mismatched closing tag appears later, so the message also names the line where the unmatched element was opened.
What is the formatted output for?
When the document is well-formed, it is pretty-printed on the right so you can copy a clean, indented version. Choose 2 spaces, 4 spaces, or tabs, and whether comments are kept.