"Valid XML" means two different things — here's the distinction

August 16, 2026·3 min read·Developer Tools

By the Converterzilla Team

We build privacy-first PDF and image tools that run entirely in your browser. Our team has shipped JavaScript file-processing apps used by thousands every day, and we write here about the libraries, trade-offs and patterns we use.

"This XML is valid" is ambiguous, and the ambiguity trips people up regularly. XML validation actually happens at two independent levels, and passing one says nothing about the other.

Well-formed: the document obeys XML's own syntax

Well-formedness is structural: every tag that opens has a matching close, tags are properly nested (not overlapping), there's exactly one root element, attribute values are quoted, and special characters like & and < are escaped where they need to be. A document can be well-formed and still be complete nonsense content-wise — well-formedness makes no claim about which elements are allowed to appear or what they should contain.

Schema-valid: the document also matches a defined structure

Schema validation checks the document against a separate contract — an XSD or DTD — that says which elements are allowed, in what order, with what attributes, and what data types their content should have. A well-formed document can fail schema validation trivially: a required element missing, an attribute with the wrong type, an element appearing somewhere the schema doesn't permit.

Why the distinction matters in practice

Most "XML validator" tools you'll find online — including the pattern most browser-based tools use — check well-formedness only, via the browser's own built-in XML parser. That's a fast, genuinely useful first check (most real-world XML bugs are well-formedness bugs: an unescaped ampersand, a mismatched tag from a hand-edited file), but a green "valid" result from a well-formedness check is not the same claim as "this will be accepted by the system that expects this specific schema." If you're integrating against an API or file format with a published XSD, well-formedness is necessary but not sufficient.

A practical order of operations

  1. Check well-formedness first — it's fast and catches the most common class of bug (unescaped characters, mismatched tags).
  2. If the document needs to conform to a specific schema, validate against that schema separately — well-formedness checking alone won't catch a missing required field or a wrong data type.
  3. If you're not sure whether a schema applies, ask whoever defined the format you're integrating against — "valid" without a schema reference is an incomplete requirement.

Our XML validator checks well-formedness locally in your browser and points at the exact line where parsing breaks — the fast first check described above, not a substitute for schema validation when one applies.

More from Developer Tools