Developer

XML Validator

Details

How to use XML Validator

What the tool does, how to run it, and what to expect from the result.

How to check whether XML is well-formed

Paste your XML and it is parsed with the browser's built-in DOMParser in XML mode on every keystroke. If the parser produces an error node, the message is shown; otherwise the document is well-formed and a re-indented copy appears in the output panel.

Nothing is uploaded, so this is safe for a config file or an API payload that contains internal data.

  • Paste the XML into the input box.
  • Read the status line: either a well-formed confirmation, or the first parse error.
  • Fix that one error and re-check, since the parser stops at the first fatal problem.
  • Watch for bare ampersands and angle brackets in text, which must be escaped as & and <.
  • Copy the re-indented output once the document parses cleanly.

The five rules that decide well-formedness

Well-formedness is a short, mechanical checklist, and almost every failure you will see here is one of five things. There must be exactly one root element wrapping everything else. Every opening tag must have a matching closing tag, or be self-closed. Tags must nest rather than overlap. Attribute values must be quoted. And the characters that mean something to the parser must be escaped when they appear in text.

That last rule causes the most confusion for anyone arriving from HTML. XML has exactly five predefined entities, < > & " and ', and a bare ampersand in text is a hard error because an ampersand always begins an entity reference. HTML parsers guess and recover; XML parsers stop. Content copied out of a web page fails here constantly for precisely that reason.

  • One root element, wrapping the whole document.
  • Every tag closed, and nested rather than overlapping.
  • Attribute values quoted, with single or double quotes.
  • Bare & and < escaped in text as &amp; and &lt;.
  • Element and attribute names are case sensitive: <Note> and <note> are different.

Well-formed is not the same as valid

These two words have precise and different meanings in XML, and conflating them is the most expensive misunderstanding in the format. Well-formed means the syntax is correct. Valid means the document also conforms to a schema, a DTD, an XSD, or a RELAX NG grammar that specifies which elements may appear, in what order, with which attributes and data types.

This tool checks the first and not the second. A sitemap with the right syntax but a misspelled element name, an invoice missing a required field, or a config with a string where a number belongs will all be reported as fine here and rejected by the system you send them to. That is still worth doing first, because a document that is not well-formed cannot be validated against anything, and the syntax errors are the ones with the least helpful downstream messages.

Tips

Getting a better result out of XML Validator

Specific settings and thresholds, not general advice.

  • This checks well-formedness, not validity in the schema sense. It confirms that tags are balanced and correctly nested, that attributes are quoted, and that the document has a single root. It does not check your XML against a DTD, an XSD, or a RELAX NG schema, so a document with the wrong elements in the wrong order can still be reported as fine.
  • The parser is the browser's own DOMParser in application/xml mode, which means the error text you get is the browser's, and it differs between Chrome, Firefox, and Safari. Two browsers may describe the same mistake in completely different words.
  • XML stops at the first fatal error and reports only that one. Fix it and re-check, because the second error is often masked by the first: an unclosed tag near the top makes everything below it look wrong.
  • The five predefined entities are &lt; &gt; &amp; &quot; and &apos;. A bare ampersand in your text (Tom & Jerry) is a hard error in XML, unlike in HTML where browsers forgive it. This catches that.
  • The pretty-printer is a string transform, not a re-serialisation of the parsed document, which is deliberate: it preserves your self-closing tags and inline text nodes instead of rewriting <br/> as <br></br>. It does mean the indentation is a best effort on unusual documents.
Limits

What XML Validator does not do

The honest boundary, so you do not lose time finding it yourself.

  • Well-formedness only; no DTD, XSD, or schema validation.
  • One error at a time (the parser stops at the first fatal error).
  • No XPath querying, no XSLT, and no namespace resolution report.
  • No file upload; you paste the XML in.
At a glance

Who XML Validator is for

A quick way to understand who this helps, what it solves, and where it connects next.

Best fit

Developers checking XML is well-formed.

Ideal for

Using the xml validator without installing anything or signing up.

FAQ

Common questions

Short answers for the questions people usually have before trying a utility like this.

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

Well-formed means the syntax is correct: one root element, every tag closed, tags properly nested, attributes quoted, special characters escaped. Valid means it also conforms to a schema that says which elements may appear where, with what attributes and in what order. This tool checks the first and not the second. A perfectly well-formed document can still be rejected by the system you send it to.

Why does the error message look so cryptic?

Because it comes straight from your browser's XML parser rather than from a custom checker. Chrome, Firefox, and Safari each phrase their parse errors differently, and some of them are terse to the point of unhelpful. What is consistent is the location: the error names the line and the construct where the parse failed, which is usually enough to spot the unclosed tag.

Why is my ampersand an error?

Because in XML an ampersand always starts an entity reference, so a bare & in text content is invalid unless it is escaped as &amp;. HTML parsers are forgiving about this and XML parsers are not, which is why content copied out of an HTML page so often fails here. The same goes for a bare < in text, which must be &lt;.

Does the formatter change my XML?

Only the whitespace between elements. It re-indents with two spaces per level using a string transform, so self-closing tags stay self-closing and an element with inline text stays on one line. It does not re-serialise the document through the DOM, which would otherwise rewrite <br/> as <br></br> and reorder your attributes.

Can I validate an XML sitemap or an RSS feed with this?

You can check that it is well-formed, which catches the most common breakages: an unescaped ampersand in a URL, an unclosed <url> element, a stray character before the declaration. What it cannot tell you is whether you have used the right elements for the sitemap or RSS schema, since that needs schema validation against the specific spec.

How do I validate XML online?

Paste it into the box on this page. There is no button and no upload: the document is parsed on every keystroke, and the status line either confirms it is well-formed or shows the first parse error. Fix that error and the check re-runs immediately, which makes working through a broken file quick.

Is my XML uploaded to a server?

No. The parsing uses the DOMParser built into your browser, so the document stays on your device and the page keeps working with the network disconnected. That is the reason this is safe for a config file, an internal API payload, or anything else you would not paste into a hosted validator.

Why does it only show one error at a time?

Because XML parsing stops at the first fatal error by design. That is in the specification, not a limitation of this tool. It also means the second error is often an illusion: an unclosed tag near the top of a document makes everything below it look wrong, and fixing the first frequently clears several apparent problems at once.

Can I upload an XML file instead of pasting?

No, there is no file picker. Open the file in any text editor, copy the contents, and paste them in. For very large documents that is worth knowing in advance, since the check re-runs on every keystroke.

Recommendations

You Might Also Like

Nearby tools from the catalog that fit the same job or workflow.

Cleanor app

Do it all on your device

Cleanor puts these tools in one app: compress and convert images, video, and audio, work with PDFs, and scan text right on your device. Plus free up storage and clear inbox clutter with Email Cleaner. Start with a free trial.

  • iPhone
  • Android
  • Macsoon
  • Windowssoon