XML Validator (Well-Formedness Check)
Checks XML for well-formedness with your browser’s XML parser and shows the failing line, or element counts and a formatted copy when it is valid. It does not validate against a DTD or XSD schema.
About the XML Validator
When an import fails with a vague parse error, or a feed reader refuses a file, the first question is whether the XML is well-formed: a single root element, every tag closed in the right order, attribute values in quotes, and special characters such as & and < escaped. Paste the document here and click Validate XML to find out.
Your browser’s own XML parser does the checking. If the document fails, you see the parser’s message, the line number and that line of your input with a caret under the reported column, which makes mistakes like <price>14.99</cost> easy to spot. The Load Broken Sample button shows what that looks like. Parsers stop at the first error, so fix it and validate again to find the next one.
If the document is well-formed, you get the name of the root element, the number of elements, attributes (including namespace declarations) and non-empty text nodes, the maximum nesting depth, and a formatted copy with 2-space indentation that you can copy.
What this does not do: it does not validate against a DTD or an XML Schema (XSD). A document can be well-formed and still break a schema’s rules, for example by missing a required element or using a date in the wrong format; checking that needs the schema and a schema-aware validator. To re-indent or minify with other options, use the XML Formatter.
How to use the XML Validator
- 1
Paste your XML
Paste the document into XML Input, or click Load Sample or Load Broken Sample to try the tool.
- 2
Click Validate XML
The result appears below the button.
- 3
Fix any error
If it says Not well-formed, go to the line shown, correct the problem and validate again.
- 4
Review and copy
For well-formed XML, check the counts and copy the formatted version if you need it.
What it can do
Standard browser parser
The same strict XML parser your browser uses for feeds and SVG files decides the result.
Line excerpt with caret
Shows the failing line of your input and marks the column the parser reported.
Document statistics
Root element, element and attribute counts, non-empty text nodes and maximum depth.
Formatted output
An indented copy of valid XML, ready to copy.
Sample documents
A valid and a deliberately broken example so you can see both results.
Limitations
- Well-formedness only: there is no DTD or XSD schema validation.
- Only the first error is reported, because XML parsers stop at the first problem.
- Error wording and the exact column differ between Chrome, Firefox and Safari.
- External DTDs and entities referenced by URL are not fetched.
Privacy
The XML is checked by your browser’s built-in parser; nothing is uploaded to FlexyPdf.
Frequently asked questions
What is the difference between well-formed and valid XML?
Well-formed means the document follows the syntax rules of XML, so any XML parser can read it. Valid means it also follows a particular schema or DTD that defines which elements and attributes are allowed. This tool checks the first; schema validation needs the schema file and a validating tool.
Why is an ampersand an error?
In XML, & starts an entity reference, so a bare & in text or in an attribute is a syntax error. Write & instead, or put the text inside a CDATA section. The same goes for <, which must be written as <.
Can I check HTML with this?
Only XHTML. Regular HTML allows things XML does not, such as <br> without a closing slash and attributes without quotes, so most HTML pages fail here even though browsers display them fine.
What does Max Depth mean?
The number of levels of nested elements, counting the root element as 1. In the sample, bookstore contains book, which contains title, so the depth is 3.
Is there a size limit?
Nothing is uploaded, so there is no fixed limit: you paste the text directly. Very large documents depend on your device’s memory and can be slow to display.
Ratings & Reviews
Rate XML Validator
Help others by sharing your experience. Your rating is shown without your name.
More Developer Tools
View all →Code Beautifier
Re-indent JavaScript, SQL, JSON, HTML, CSS and XML code
JSON Formatter & Validator
Validate, pretty-print or minify JSON
Markdown Editor
Write Markdown with a live GitHub-style preview
Live Code Editor
Edit HTML, CSS and JavaScript with a live preview