How do I validate XML online?
Paste your XML into the input box, open a file with Open file… or drop one onto the tool. Then press Validate, or Ctrl+Enter (⌘+Enter on a Mac). The verdict appears in the Result box. When the XML is well-formed, you also see its lines, elements, size, encoding and root element.
When it isn't, you get the line and column of the first error, a plain-English explanation and the lines around it. Go to error selects that spot in the input, so you can fix it and check again.
What does well-formed XML mean?
Well-formed XML follows the syntax rules of the XML 1.0 specification. There is exactly one root element, every start tag has a matching end tag, elements close in the reverse order they were opened, attribute values sit in quotes, and the characters & and < are written as & and < in text. A parser refuses a file that breaks any of these rules, so one stray character can stop a feed or a sitemap from loading.
Common XML syntax errors and how to fix them
Most broken files come down to a few mistakes: a closing tag with a typo, such as </autor> for <author>; a tag that is never closed; an & in a URL or a company name; an attribute value without quotes; two root elements; an invisible control character copied from another program. The validator names each of them and suggests a fix. Parsers stop at the first error, so validate again after each fix to find the next one.
Does this XML validator check XSD or DTD schemas?
No. It checks that the XML is well-formed. A schema adds its own rules, such as which elements are allowed, and checking against one needs the schema file. The tool reads the DOCTYPE and its internal declarations to check their syntax, but it never downloads an external DTD.
Does this XML validator upload my file?
No. The check runs in this browser tab. Your file is read on your device, and the security rules of this page stop it from sending anything. Nothing is saved: close the tab and it is gone. The XML formatter can then indent or minify it. For a sitemap, use the sitemap checker; for JSON, the XML to JSON converter; for XSLT, the XSLT tester; for XPath, the XPath tester.
Questions
Is well-formed XML the same as valid XML?
No. Well-formed means the syntax is correct. Valid means the file also follows a DTD or XSD schema, which this tool does not check. A file has to be well-formed before it can be valid.
How can I check XML syntax without a website?
In a terminal, xmllint --noout file.xml prints nothing when the file is well-formed, and the errors it finds, with their line numbers, when it is not. Most code editors do it too with an XML extension.
Is there a file size limit?
Yes, 20 MB for an opened file or for pasted text. The check runs in the background, so the page stays responsive.
Why does it show only one error?
XML parsers stop at the first error, because the rest of the file can no longer be read reliably. Fix it, validate again, and the next error shows up if there is one.
Can it fix my XML?
No. It points to the first error and explains it, and you decide how to fix it. An automatic fix could silently change your data.
Can I check XML directly in Chrome?
When Chrome opens XML that is not well-formed, it shows an error with a line and column at the top of the page. XMLNest, an extension available on the Chrome Web Store, shows XML files as a readable tree and points to the error when a file is broken.