Paste XML or open a file to check that it is well-formed. The first parser error is pinned to its exact line and column with a plain-English fix, a second scan lists other problems, and valid XML is pretty-printed for you.
Last updated:
XML input
1
Ln 1, Col 10 B
Pretty-printed XML
Advertisement
Advertisement
How to use the XML Validator
Paste your XML into the editor, open a file, or drag one onto the editor. It is checked automatically.
Read the result. Green means well-formed. Red shows the line, column, the parser's message and what it means.
Press Go to error to jump to the problem, or click any item under Other problems found.
Fix and re-check. The check reruns as you type; press Check XML or Ctrl + Enter if live checking is off.
Copy or download the pretty-printed XML, or press Format input to replace your text with it.
Common XML errors and how to fix them
Parser message (Chrome/Edge)
Broken
Fixed
Opening and ending tag mismatch
<price>24</Price>
<price>24</price>
xmlParseEntityRef: no name
<name>Salt & Pepper</name>
<name>Salt & Pepper</name>
AttValue: " or ' expected
<item id=7>
<item id="7">
Extra content at the end of the document
<a/><b/>
<root><a/><b/></root>
StartTag: invalid element name
<if>x < 5</if>
<if>x < 5</if>
Entity 'nbsp' not defined
<p>10 km</p>
<p>10 km</p>
Attribute x redefined
<img src="a" src="b"/>
<img src="a"/>
Namespace prefix … is not defined
<media:thumb/>
<media:thumb xmlns:media="…"/>
XML declaration allowed only at the start
blank line before <?xml …?>
<?xml …?> as the first characters
Premature end of data in tag
<list><li>1</li>
<list><li>1</li></list>
Firefox words the same errors differently, for example "mismatched tag", "not well-formed", "junk after document element" or "undefined entity". The hint under the message explains each of them in plain English.
The well-formedness rules in short
One root element contains everything else. Comments, processing instructions and a DOCTYPE may appear before or after it, but no other elements or text.
Tags nest properly. Every <tag> has a matching </tag>, or is written as an empty element <tag/>. The last opened element closes first.
Names are case-sensitive and must start with a letter or underscore. <Item> and <item> are different elements; <2nd> is not a valid name.
Attribute values are always quoted with " or ', every attribute has a value, and a name appears only once per element.
Escape the special characters. In text write & as & and < as <. Inside attribute values also escape the quote character you used. Alternatively wrap text in <![CDATA[ … ]]>.
The XML declaration<?xml version="1.0" encoding="UTF-8"?> is optional, but when present it must be the very first thing in the file.
Tips for tracking down errors
Fix the first reported error and check again: one missing closing tag can make everything after it look wrong. When the reported line looks fine, look a few lines above it, because the parser only stops when the mistake becomes impossible to ignore. Files exported from spreadsheets or databases often break on unescaped ampersands in company names and URLs, while files edited by hand usually break on mismatched case or a forgotten closing tag.
Frequently asked questions
What does well-formed XML mean?
Well-formed XML follows the basic syntax rules of the XML 1.0 specification: exactly one root element, every start tag closed by a matching end tag in the right order, attribute values in quotes, no repeated attribute on one element, and the characters & and < escaped in text. A document that breaks any of these rules is not XML at all, and every XML parser must reject it.
Is well-formed the same as valid?
No. Well-formed means the syntax is correct. Valid means it also follows a DTD or XML Schema (XSD) that defines which elements and attributes are allowed. This tool checks well-formedness, which is what every parser requires; it reports when a DTD or XSD is referenced but does not download or apply it.
Why does it say Opening and ending tag mismatch?
A closing tag does not match the element that is currently open. Common causes are a missing closing tag earlier in the file, tags closed in the wrong order, such as <b><i></b></i>, or a case difference, because XML names are case-sensitive: <Price> and </price> do not match.
How do I fix an error about & or EntityRef?
A bare ampersand is not allowed in XML text or attribute values. Write it as &, for example ?a=1&b=2 in a URL. Only &, <, >, " and ' are predefined; HTML entities such as must be written as numeric references like   unless a DTD defines them.
Why is the error reported on a later line than the real mistake?
A parser only notices a problem when it reads something that cannot be correct. A tag left open on line 5 may only be detected when the parent closes on line 40. Check the list of other problems and the lines just above the reported position.
Is my XML uploaded to a server?
No. The XML is parsed by the DOMParser built into your browser and all checks run locally on your device. Nothing is sent anywhere, so it is safe for configuration files and private data.
Can it check SVG, RSS, sitemap or KML files?
Yes. These formats are all XML, so they must be well-formed. Open the file or paste its content to check it. The tool checks syntax, not format-specific rules such as required RSS channel elements.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.