XML Validator
Check that an XML document is well formed before you ship a feed, sitemap, SVG or configuration file. The validator scans tags, attributes, nesting and characters, and reports the first problem with its line, column and the parser's explanation, such as a closing tag that does not match. Well-formed documents show the root element, the number of elements and attributes and the nesting depth. It checks well-formedness, not DTD or XSD rules.
Frequently asked questions
How does well-formed XML differ from valid XML?
Well-formed XML follows the basic syntax rules: one root element, properly nested and closed tags and correctly quoted attributes. Valid XML additionally matches a DTD or XML Schema that defines which elements are allowed. This tool checks well-formedness, which every XML parser requires before anything else.
What exactly is checked?
The validator checks that there is exactly one root element, that every tag is closed in the right order, that tag and attribute names are allowed, that attribute values are quoted and not repeated and that no stray characters appear outside elements. The XML declaration, comments, CDATA sections and processing instructions are accepted.
What do the error types mean?
Errors fall into four groups: document structure, tags, attributes and characters. The error line names the group in plain language, and the details line gives the parser's exact explanation, for example which tag was expected. Both come with the line and column of the problem.
Why is an attribute without a value rejected?
HTML allows boolean attributes such as <input disabled>, but XML requires every attribute to have a quoted value. Write disabled="disabled" or remove the attribute. The same rule applies to SVG and XHTML files.
Can I validate HTML with it?
Only XHTML, which is HTML written as XML. Regular HTML leaves elements such as <br> or <img> unclosed and allows unquoted attributes, which XML does not, so it will usually be reported as not well formed.
Are DOCTYPE declarations and entities supported?
A DOCTYPE with entity declarations is accepted as part of the syntax check, but entities are never expanded and no external files are fetched. This keeps the check fast and safe against entity expansion attacks. The predefined entities such as & and < are always allowed.
Are namespaces supported?
Prefixed names such as svg:rect or xsi:schemaLocation are accepted as element and attribute names. The validator does not resolve namespace URIs or check that every prefix is declared.
What do the statistics of a valid document show?
The root element is the outermost tag, Elements counts every element including the root and Attributes counts all attributes in the document. Maximum depth is the deepest level of nesting, where the root is level 1. These numbers help to confirm that a feed or export contains what you expect.
How are line and column numbers counted?
Both start at 1 from the beginning of the input. The position points to where the parser noticed the problem, which for an unclosed tag can be the opening tag itself. Only the first error is reported.
How large can the XML be, and can I convert it?
Inputs can be up to 5 MiB. To turn a well-formed document into JSON, YAML, CSV or another format, use the Data Format Converter or the XML to JSON tool.