About the XML Validator
A well-formed XML document has one root element, every tag closed in the right order, quoted attribute values, and only the five predefined entities unless others are declared. This validator uses the browser's own XML parser, the same engine that loads XML in the page, and reports its first error with a line number and a plain description.
When the document passes, you get a short profile: root element name, number of elements, attributes and text nodes, the deepest nesting level, and the default namespace if there is one. That profile is a quick way to sanity-check a generated file, for example to confirm that an export contains the number of records you expected.
This is well-formedness checking, not schema validation. It does not compare the document to an XSD, DTD or RelaxNG grammar, so it cannot tell you that a required element is missing. Most XML errors in practice are well-formedness errors, and those are what this tool finds.
How to use
- Paste the XML or upload the file.
- Read the result: a profile for valid documents, or the error line and column for invalid ones.
- Fix the reported spot in the left pane; the result updates as you type.
Common questions
- What is the difference between well-formed and valid XML?
- Well-formed means the syntax is correct. Valid means it also follows a schema. This tool checks the first; schema validation needs the schema file and is not offered here.
- Why does the error say "junk after document element"?
- XML allows exactly one root element. Text or a second element after the closing root tag triggers this message. Wrap everything in a single root.
- Does it detect unescaped ampersands?
- Yes. A bare & must be written as
&, and the validator points to the exact spot. - Does it support DTD entity declarations?
- Internal DTD subsets with entity declarations are parsed. External DTDs are not fetched, because nothing leaves your browser.