XML Validator
Check that XML is well-formed and get the line and column of the first error, with a summary of elements, attributes and namespaces.
XML Validator: the tool
XML to check
Report
The validation report appears here.How to use XML Validator
- Paste XML into the left panel, or press Example to load a document with two mistakes.
- If it is well-formed, the report lists the root element, the number of elements and attributes, nesting depth, namespaces and the declared version and encoding.
- If it is not, the status bar shows the line, the column and what is wrong. Press Go to error to jump to the position.
- Fix the first error and the next one, if any, appears. XML parsers stop at the first problem, and so does this tool.
Example
A catalog with an unescaped ampersand and a closing tag that does not match. The first problem is reported.
<catalog>
<book id="b1">
<title>Networks & Protocols</title>
</boo>
</catalog>Not well-formed · line 3, column 21: A bare '&' is not allowed. Write & for an ampersand.
Result Well-formed XML Root element <catalog> Elements 3 (3 distinct names) Attributes 1 Nesting depth 3 Text nodes 1 Comments 0 CDATA sections 0 Size 64 B as UTF-8
About this tool
A well-formed XML document follows the syntax rules that every parser enforces: one root element, properly nested and matching tags, quoted attribute values, unique attribute names, escaped special characters, and only characters that XML 1.0 allows. A document that breaks any of them is rejected completely, with no partial result, which is why a precise error position matters.
Messages explain the cause. A mismatch says which closing tag was expected, and on which line the open tag started. A bare ampersand points at the & and suggests &. An undefined entity such as is reported, because XML predefines only five entities, unlike HTML.
This is a well-formedness check. The document is not validated against a DTD or an XML Schema (XSD), and namespace prefixes are not checked, so the report says so every time. Everything runs in your browser and nothing is uploaded.
Typical XML errors
| Problem | Example | Fix |
|---|---|---|
| Mismatched tag | <a><b></a></b> | Close elements in reverse order |
| Bare ampersand | <a>Tom & Jerry</a> | Write & |
| Unquoted attribute | <a id=1/> | Write id="1" |
| Undefined entity | <a> </a> | Use   or the character itself |
| Two root elements | <a/><b/> | Wrap them in one parent |
| Duplicate attribute | <a x="1" x="2"/> | Keep one |
Frequently asked questions
What does well-formed mean?
That the document obeys XML's syntax rules, so any XML parser can read it. It does not mean that the content is correct for your application. That is what validity against a schema checks.
Does this validate against an XSD or DTD?
No. It checks well-formedness only, and the report reminds you of that. Use a schema-aware tool when you need to check structure and data types.
Why is an error?
XML predefines only &, <, >, " and '. HTML entities such as or © are unknown unless a DTD declares them. Use a numeric reference, for example  .
Why does it report only one error?
XML parsers stop at the first fatal error, because after a syntax error the rest of the text cannot be interpreted reliably. Fix it and check again.
Does it accept the XML declaration and a BOM?
Yes. The declaration must be at the very start of the document, in lowercase, and a leading byte order mark is accepted.
More developer tools
- <x>XML FormatterBeautify or minify XML after checking that it is well-formed. Mixed content, CDATA and comments are kept intact.
- →xmlJSON to XML ConverterConvert JSON to well-formed XML with a root element you choose. Arrays repeat their element, and invalid names are repaired and reported.
- ok?JSON ValidatorCheck JSON against the specification and get the exact line and column of the first error, plus a summary of what the document contains.
- ymlYAML Formatter & ValidatorValidate and re-indent YAML while keeping comments, anchors and tags. Syntax errors point to the exact line and column.