Skip to content
ZeroServer.tools

XML Validator

Check XML well-formedness with the browser's native XML engine — namespace-, CDATA-, and entity-aware.

How XML validation works

This tool checks that your XML is well-formedusing the browser’s built-in DOMParser— the same XML engine the browser itself uses. That means it correctly handles namespaced tags (e.g. <soap:Envelope>), CDATAsections, character entities, and attribute values — and it reports the exact line and column of the first error. It does not validate against a DTD or XSD schema; for structural validation you need a full schema.

After fixing errors, you can format your XML with XML Formatter, or convert it to JSON with XML to JSON.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Getting a line and column for a failure a build tool reported without one.
  • Finding the unclosed tag in a hand-edited file.
  • Checking generated XML after a template change.
  • Reviewing a document from another team before relying on it.
  • Spotting an unquoted attribute value quickly.

Frequently Asked Questions

What does well-formed mean?
Syntactically correct: one root element, every tag closed and correctly nested, attribute values quoted, and the five reserved characters escaped. A well-formed document parses; it says nothing about whether the elements are the ones a schema expects.
How is validity different from well-formedness?
Validity is conformance to a schema — a DTD, XSD or RELAX NG — which defines which elements may appear where and what they may contain. A document can be perfectly well-formed and completely invalid, and most XML errors in practice are the first kind.
Which characters must be escaped?
`&` and `<` always, and `>` by convention. Inside a double-quoted attribute value `"` must be escaped too, and `'` inside a single-quoted one. An unescaped ampersand is the single most common cause of a document failing to parse.
What does CDATA do?
Marks a block whose content is not parsed, so `<` and `&` can appear literally — useful for embedded code or markup. It has one hard limit: the sequence `]]>` cannot appear inside it, and there is no escape for that within CDATA itself.
Why does the encoding declaration matter?
Because a parser must know the encoding before it can read the document, and the declaration is inside the document it is trying to read. XML resolves this by requiring the declaration to be pure ASCII at the very start — which is why nothing may precede it, not even a byte-order mark in some parsers.

Common errors and gotchas

  • Confusing well-formed with valid, since a schema can still reject a document that parses.
  • Feeding in HTML, where unclosed tags are legal and here are fatal.
  • Overlooking an unescaped ampersand, which is the most common well-formedness error there is.
  • Assuming namespaces are checked, which well-formedness does not cover.
  • Validating a fragment as a document, where a single root element is required.

Related Formatters & Validators tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate