Skip to content
cliplimeClipLime

Check that your XML is well-formed

Paste XML and see if it follows the syntax rules. If not, you get the line, the column and what is likely wrong.

Your text is processed in this tab and never uploaded

Options

0 characters, 0 lines Your text stays in this tab.

Result

The result appears here.

This checks that the XML is well-formed. It does not validate against a DTD or XSD schema, and nothing is downloaded.

At a glance

What it checks
That the XML is well-formed: it follows the syntax rules of XML 1.0.
Reports
Root element, XML version, encoding label, size, element and attribute counts, depth, comments, CDATA, namespaces and DOCTYPE.
Errors
The line and column, the faulty line with a marker, and a likely cause.
Second opinion
In the browser, documents up to 3 MB are also checked by the built in XML parser.
Notes
Warns when the encoding label is not UTF-8, and when a DOCTYPE points to an external DTD.
Not checked
DTD and XSD validity. Nothing is downloaded.
Privacy
Runs in your browser tab. Your XML is never uploaded.

How to do it

  1. 1

    Paste XML or drop a file

    Paste into the left box or drop an .xml, .svg or similar file on it. The check runs as you type.

  2. 2

    Read the verdict

    A green card says Well-formed XML and lists what the document contains. A red card names the problem with its line and column.

  3. 3

    Fix the first error

    Press Go to line to jump to it. Only the first problem is shown, because later ones are often caused by it.

  4. 4

    Format it if you like

    Switch to Format to indent the checked document.

Well-formed and valid are different

XML has two levels of correctness. A document is well-formed when it follows the syntax rules: one root element, tags that match, quoted attributes, escaped special characters. A document is valid when it is well-formed and also obeys a schema, such as a DTD or an XSD, that says which elements and attributes are allowed.

This tool checks the first level. It will tell you whether the text is XML, not whether a particular program will accept it. For the second level, use a validator that has your schema.

What the checks cover

  • Exactly one root element, and no text outside it.
  • Every start tag has a matching end tag, in the right order and with the same capitals.
  • Element and attribute names use only the characters XML allows.
  • Attributes have a value in single or double quotes, and no name is repeated on one tag.
  • No raw < inside an attribute value, and no ]]> in text.
  • Every & starts a real entity: one of the five predefined names, a number such as &#65;, or a name declared in the DOCTYPE.
  • Namespace prefixes are declared by an xmlns:prefix attribute on the element or one of its parents.
  • Comments do not contain two hyphens in a row, and CDATA sections and processing instructions are closed.
  • The XML declaration, if present, is the first thing in the document and is written in the right form.
  • No control characters that XML 1.0 forbids.

Reading the report

Encoding label is the encoding value in the declaration. The text you paste is already decoded by the browser, so the label is not used to read it, but a program that reads the saved file will trust it. A warning appears if the label is not UTF-8, because that is the encoding of anything you copy or download from this page.

Nesting depth is how many elements are open at the deepest point. Namespaces lists each xmlns declaration it found. A DOCTYPE that points to an external DTD is noted, because entities and rules defined in it are not loaded.

Why an XML document is rejected

Browsers and XML libraries are strict on purpose: a document that is not well-formed is not partly read, it is refused. That is why one stray & in a long file can make the whole file fail in another program.

The messages here name the tag that is still open and the line where it began, so you can see where the nesting went wrong. If you are really looking at HTML, use the HTML formatter, which accepts unclosed tags. To lay out a document that already passes, use the XML formatter.

Questions people ask

Does this validate against an XSD or a DTD?

No. It checks well-formedness only. Schema validation needs the schema and a schema aware validator. If a DOCTYPE links to an external DTD, nothing is downloaded.

What is the difference between well-formed and valid XML?

Well-formed means the syntax is correct. Valid means it is well-formed and also follows a schema. Every valid document is well-formed, but a well-formed document may not be valid.

Why was my SVG or RSS feed rejected?

The usual causes are an unescaped & in a URL, a missing closing tag, an undeclared namespace prefix such as xlink:, or a blank line before the <?xml declaration. The message gives the line and column.

Why does it show only one error?

After the first syntax error the reader cannot know what the author meant, so later messages are often side effects of it. Fixing the first problem and checking again is more reliable.

Is a missing XML declaration an error?

No. The declaration is optional, and without it the document is read as XML 1.0 in UTF-8. If you include it, it must come first and be written in the right form.

Is my XML uploaded?

No. The check runs in your browser tab, including the built in parser's second opinion.