XML Validator
Check whether XML is well-formed and find errors by line and column, with the surrounding lines. Shows the root element, element count, depth and namespaces.
Well-formed XML
- Root element
- Elements
- Attributes
- Depth
- Namespaces
Not well-formed — Line , column
Runs in your browser. What you enter is kept for 30 days to improve Toolgrid, then deleted.
How to use the XML Validator
- 1 Paste your XML.
- 2 See immediately whether it is well-formed, or where the first error is.
- 3 Fix the error and check again.
About the XML Validator
Well-formed XML follows the basic rules of the XML specification: one root element, every start tag closed by a matching end tag (or self-closing), properly nested elements, quoted attribute values, unique attributes per element, and special characters such as & and < escaped. Any XML parser refuses a document that breaks these rules.
The validator parses your document with the browser's standards-compliant XML parser. If it fails, you see the parser's message with the line and column of the first error and the lines around it. Parsers stop at the first error, so after fixing it, check again to find the next one.
Well-formed isn't the same as valid against a schema: checking that a document follows a DTD, XSD or RELAX NG schema (the right elements in the right order) needs that schema and a validating parser. For the structure, the summary shows the root element, the number of elements and attributes, the nesting depth and the namespaces used.
Frequently asked questions
What does "well-formed" mean?
That the document follows XML's syntax rules: one root, matching and properly nested tags, quoted attributes and escaped special characters.
Does it validate against an XSD or DTD?
No, it checks well-formedness only. Schema validation needs the schema file and is usually done in your editor or build pipeline.
Why does & give an error?
In XML, & starts an entity reference. Write a literal ampersand as & (and < as <), or put text in a CDATA section.
Is HTML valid XML?
Usually not: HTML allows unclosed tags like <br> and attributes without quotes. XHTML is HTML written as well-formed XML.