How to use XML Validator
- Paste your XML into the Input box, or click Open a file to load an .xml file.
- Read the sentence under Result. For well-formed XML it gives the root element, the number of elements and attributes and the nesting depth.
- If the XML is not well-formed, the red message gives the line, the column and the reason. Fix that spot and the result updates as you type.
Features
- Checks well-formedness as you type
- Shows the root element and the number of elements, attributes and nesting levels
- Reports line, column and reason for the first error
- Catches unclosed or mismatched tags, unquoted attributes and more than one root element
- Says clearly that DTD and XSD validation is not performed
- Runs in your browser, so the XML is never uploaded
Supported formats and limits
- Maximum input: 10,000,000 characters
Examples
| Input | Result |
|---|---|
| <?xml version="1.0"?> <library> <book id="1"><title>Dune</title></book> <book id="2"><title>Emma</title></book> </library> | Well-formed XML: root element <library>, 5 elements, 2 attributes, nesting depth 3. Well-formedness only: the document is not checked against a DTD or XSD. |
| <a> <b></a> | Invalid XML at line 2, column 4: Expected closing tag 'b' (opened in line 2, col 1) instead of closing tag 'a'. — The tag b was opened but a was closed first. |
| <a attr=1/> | Invalid XML at line 1, column 4: Attribute 'attr' is without value. — Attribute values must be in quotes. The reason is shown in English, as returned by the parser. |
Limitations
- The tool checks well-formedness only. It does not validate the document against a DTD or an XSD schema.
- Only the first error is reported, so a document with several problems may need a few rounds of fixing.
- It does not fetch external entities or other files that the document refers to.
- Very large files can be slow to process in the browser.
Learn more
An XML document is well-formed when it satisfies the syntax rules in the W3C XML 1.0 specification. There must be exactly one root element, every start tag needs a matching end tag, elements must nest without overlapping, attribute values must be quoted, and names must use legal characters. The characters & and < in text must be written as entities such as & and <.
A conforming XML parser has to reject a document that breaks these rules, which is why well-formedness is the first check to run on any XML that comes from an export, an API or a configuration file. The line and column in the error message point to where the parser noticed the problem, which is often just after the actual mistake.
Validity is a separate, stronger property. A valid document also follows a schema, written as a DTD or an XSD, that defines which elements and attributes are allowed and in what order. Schema validation needs the schema file and a validating parser, and this tool does not perform it.
Frequently asked questions
What is the difference between well-formed and valid XML?
Well-formed XML follows the syntax rules of the XML specification. Valid XML is also checked against a schema, such as a DTD or an XSD. This tool does the first check only.
Can this tool validate XML against an XSD?
No. It checks that the XML is well-formed, but it does not read or apply a DTD or an XSD.
Why is my XML reported as invalid?
Common causes are a tag that is not closed, tags closed in the wrong order, an attribute value without quotes, more than one root element, or a raw & or < in text. The message shows the line and column.
Does the XML declaration have to be there?
No. The declaration at the top, such as the version line, is optional. If it is present, it must be at the very start of the document.
Is my XML uploaded?
No. The check runs in your browser.
Sources
Last reviewed: September 30, 2026