XML Validator
Validate XML syntax and see each error with its line number
Input XML
Validation Result
Paste your XML on the left and the result shows up here.
Or drop a file on this box, , or .
What is XML Validator?
Need to know whether your XML will parse? Paste it here and the validator checks it as you type. If something is wrong, you get the parser's message with the line and column; if it is fine, you get a short summary of the document: root element, element and attribute counts, depth and namespaces.
What it checks is well-formedness as defined by the W3C XML specification: every tag closed and properly nested, attribute values quoted, a single root element, no bare & or < in text. It does not check your document against an XSD or DTD. MDN's XML introduction is a good primer on the rules.
A passing result also tells you whether the document opens with an XML declaration and which encoding it names, handy when a downstream system insists on UTF-8. The check itself is done by the parser built into your browser, so the document is never posted anywhere to be validated.
How to Use the XML Validator
Checking is continuous. Every edit in the left pane re-runs the check, so the verdict on the right always matches the text you are looking at.
Paste, Upload, or Load Sample
Put the document in the left Input XML pane, or use Upload to open a .xml file from disk. Sample loads two subscribers with an id attribute and five child elements each, including an escaped AT&T. The short form of that data:
<subscribers><subscriber><subscriberId>SUB-1001</subscriberId><plan>Unlimited 5G</plan><dataUsage>45.2</dataUsage></subscriber></subscribers> Use Clear to start fresh. The validator checks your XML as you type.
View Validation Result
The right Validation Result panel shows VALID or INVALID. Invalid XML shows the parser's error message, which includes the line and column where it gave up. Valid XML shows a document summary.
Fix and Revalidate
Go to the line and column the message names, fix the tag or entity, and the badge flips to VALID as soon as the document parses. For the sample, the summary then lists 13 elements with 7 distinct names, 2 attributes and a maximum depth of 3. If you also want it indented, the XML Formatter is the next stop.
When You'd Actually Use This
API Development
Check XML responses from SOAP services or REST APIs before you write parsing code, so you know whether a failure is your code or a broken payload.
Config File Checks
Before deploying, validate your XML configuration files. One syntax error can break your entire application. Catch it early with the validator.
Learning XML
If you are still getting used to XML, write a few elements by hand and break them on purpose: drop a closing tag, swap two, leave an ampersand bare. Seeing the message each mistake produces makes real parser errors much easier to read later.
Debugging
Getting parsing errors in your code? Validate the XML first. Detailed error messages help you find the exact problem faster than trial and error.
Common Questions
Is my XML uploaded?
No. Validation happens in your browser with its built-in XML parser; your XML never leaves your computer.
What makes XML invalid?
The usual suspects: a missing or misspelled closing tag, elements closed in the wrong order, an unquoted attribute value, a bare & that should be &, text or a second element after the root closes, or any content at all (a blank line counts) ahead of the <?xml ...?> declaration. Leading whitespace is trimmed here, so that last one will not trip you up on this page.
Does it validate against an XML Schema (XSD)?
No. It checks well-formedness only. To validate against an XSD, use xmllint --schema from libxml2 or your language's schema validator.
Which parser does it use?
Your browser's own XML parser (the one behind DOMParser), which implements XML 1.0. The exact wording of error messages differs between Chrome, Firefox and Safari.
Can I validate large files?
Up to 10 MB. Files of a few MB validate in a moment; for bigger ones use xmllint --noout on the command line.
Can it fix my XML?
No, it only reports the problem. The XML Fixer can try to repair broken XML for you.
Other XML Tools You Might Need
A document that passes here is ready for its next job, whether that means indenting it for review, shrinking it for transport or turning it into JSON, CSV or YAML: