An unescaped ampersand
Input
<company>Ben & Jerry</company>
Result
An "&" must start an entity such as &. Line 1, column 15.
Write it as Ben & Jerry. The same applies to a literal < inside text.
Check whether an XML document is well formed, with the line, column, and cause of the first error.
Start here Paste the exact document, including the XML declaration if there is one.
Well formed means the syntax parses. It does not mean the document matches a DTD or an XML Schema, which is a separate check against a contract.
Understand the format
Well formed and valid are two different checks, and most "invalid XML" errors are really the first one: the document does not parse at all.
A well-formed document obeys the syntax of XML: one root element, every tag closed, tags properly nested, attribute values quoted, and reserved characters escaped. Any XML parser can check this without knowing anything about your data. That is the check this page performs.
A valid document is well formed and also matches a declared contract, a DTD or an XML Schema, which says which elements may appear, in what order, with which attributes and data types. A document can be perfectly well formed and still be rejected by a service because an element is missing or a date is not a date. Checking syntax first is worth the ten seconds, because it removes an entire class of confusing failures.
The line and column reported here point at the first place the grammar was broken, which is often slightly after the real mistake. An unclosed element is a good example: the parser only discovers the problem when it meets a closing tag that does not match, or when the document ends. Read the position as a starting point and scan backwards for the nearest unbalanced tag.
Documents copied from a terminal or a log viewer bring their own failure modes: a truncated tail, a byte-order mark before the declaration, smart quotes substituted by an editor, or an ampersand in a customer name that was never escaped.
XML predefines only & < > " and '. Everything else, including the that HTML authors reach for by reflex, must be declared in a DTD or written as a character reference such as  . An undefined entity makes the document not well formed, which is why a stray stops a whole feed from parsing.
A bare ampersand is the same mistake in a different disguise. "Ben & Jerry" inside an element is a syntax error; it has to be "Ben & Jerry". This is by far the most common cause of a document that looks fine to a human and fails on the first parse.
Step by step
Validation runs entirely in your browser using a parser written for this site, which means malformed data, internal element names, and copied payloads stay on your machine.
Worked examples
Input
<company>Ben & Jerry</company>
Result
An "&" must start an entity such as &. Line 1, column 15.
Write it as Ben & Jerry. The same applies to a literal < inside text.
Input
<b><i>text</b></i>
Result
Closing tag </b> does not match the open element <i>.
XML requires strict nesting. HTML browsers forgive this; XML parsers never do.
Reference
| Rule | Breaks it | Correct |
|---|---|---|
| Exactly one root element | <a/><b/> | <root><a/><b/></root> |
| Every element is closed | <a><b></a> | <a><b/></a> |
| Tags nest, never overlap | <b><i></b></i> | <b><i></i></b> |
| Element names are case sensitive | <Note></note> | <note></note> |
| Attribute values are quoted | <a id=1/> | <a id="1"/> |
| An attribute appears once per element | <a id="1" id="2"/> | <a id="1"/> |
| & and < are escaped in text | <a>Ben & Jerry</a> | <a>Ben & Jerry</a> |
Practical Guide
Troubleshooting
FAQ
Well formed means the syntax is correct and any parser can read it. Valid means it also matches a declared DTD or XML Schema. This page checks the first; a schema validator checks the second.
No. Schema validation needs your schema and is normally done in your own build or service, where the schema is versioned alongside the code.
Because a bare & starts an entity reference. Any literal ampersand in text or in an attribute value has to be written &.
No. Exactly one element contains everything else. If you are producing a stream of records, wrap them in a single container element.
No. A document must have a root element, so an empty file or a file containing only a comment fails.
No. The parser runs in this page, so supplier feeds and internal payloads never leave your machine.
Go deeper