TL;DR: Paste XML and press Validate XML. You get either a structural report — root element, element and attribute counts, nesting depth — or a list of errors, each with its line, column and a caret pointing at the exact character. The check runs in your browser; the document is never uploaded.
An XML validator answers one question: is this document well-formed? That is different from asking whether it is valid against a schema. Well-formedness is about syntax — one root element, correctly nested and closed tags, quoted attribute values, legal entity references, no stray text outside the root. A document can be perfectly well-formed and still fail an XSD schema; that second check needs the schema document, which a browser-side tool cannot invent.
This validator uses a custom tokenizer and parser written for this site, so the messages are identical in every browser and the position is precise. It is the same engine that powers the XML Formatter and the XML Minifier, which is why a document that validates here also formats and minifies cleanly.
How to validate XML online
Paste or load your XML
Paste into the left editor, or press Load broken sample to see what error reporting looks like before you use it on real data. The pane header shows the input size.
Press Validate XML
The parser reads the whole document before reporting. Errors are collected rather than stopping at the first one, so a single typo does not hide what comes after it.
Read the location and the fix
Each error starts with a line and column, then a sentence explaining what the parser expected and a hint for the usual fix. The code frame underneath marks the exact character.
Fix, paste again, repeat
When the document passes, the result pane shows a structural summary: root element, element count, attribute count, maximum depth, text nodes, comments, CDATA sections and input size.
What well-formed XML requires
Well-formedness is a short list of rules, and almost every real XML failure is a violation of one of them:
- Exactly one root element. Comments and processing instructions may sit around it; elements and text may not.
- Every start tag is closed, either as
<tag/>or with a matching</tag>, and nested elements close in reverse order. - Tag names are case-sensitive.
<Item>and</item>are different names. - Attribute values are quoted with single or double quotes, and an attribute appears only once per element.
- Ampersands and angle brackets are escaped in text —
&,<,>— or the text is wrapped in CDATA. - Only predefined or declared entities are used. XML defines
&,<,>,"and', plus numeric references such as©. - Comments cannot contain
--, and CDATA sections must end with]]>. - The XML declaration, if present, is first — no spaces, BOM or comments before it.
Reading the error report
Errors are printed in source order. Each block contains three things: the location (Line 12, Column 8), the reason (“Closing tag </item> does not match the open <items> tag”) and a fix hint (“XML tag names are case-sensitive”). Under the hint, a code frame shows the offending line with a caret under the column, so even a long line with many attributes is easy to scan.
When the parser has to recover, it shows the most specific error and suppresses follow-on noise. An unterminated comment, for example, produces “Comment is never closed” rather than a second message claiming that every following tag is missing. Up to five errors are displayed per run; fixing them and running again usually surfaces anything that remains.
Common XML errors and their messages
| Error | What the validator prints | Typical fix |
|---|---|---|
| Unclosed element | <body> (opened on line 5, column 3) is never closed. | Add </body> before the parent’s closing tag. |
| Mismatched closing tag | Closing tag </titl> does not match the open <title> tag (opened on line 7, column 5). | Correct the spelling; names are case-sensitive. |
| Unquoted attribute | Attribute value must be quoted. Write id="1" instead of id=1. | Add quotes around every attribute value. |
| Raw ampersand | A literal “&” must be escaped as &. | Escape it, or wrap the text in CDATA. |
| Unknown entity | Unknown entity “ ” — XML only defines the five predefined entities and numeric references. | Use   or the literal character. |
| Duplicate attribute | Duplicate attribute “id” on <item>. | Remove the repeated attribute. |
| Two root elements | Only one root element is allowed. Found a second root <order> after <catalog>. | Wrap the content in one container element. |
| XML declaration not first | The XML declaration must be the very first thing in the file. | Remove whitespace, comments or stray characters before <?xml ...?>. |
Well-formed vs valid: what this validator does not check
Well-formedness is the syntax layer. Validity is the schema layer: does <price> contain a decimal, is the id attribute allowed here, is the element order correct? Those rules live in an XSD or DTD document, and checking them requires that document too. This page does not fetch or upload schemas — doing so would change both the privacy story and the size limits.
If you need schema validation, xmllint --schema schema.xsd file.xml is the standard command-line answer, and most IDEs have a schema-aware XML plugin. A practical workflow is to check well-formedness here first (fast, no setup), then run the schema check in the build pipeline where the schema already lives.
Namespaces are another thing a pure syntax check cannot settle. The validator accepts prefixes such as <soap:Envelope> as long as the syntax is right; it does not verify that the prefix is declared or that its namespace URI resolves to anything.
What the validation report includes
When the document passes, the report lists the root element, element count, attribute count, maximum nesting depth, number of text nodes, comments, CDATA sections, processing instructions and the exact input size in bytes. That summary is a useful sanity check of its own — a document you expected to contain 400 elements but which reports 4 is suspicious before you ever load it.
The report also counts attributes and text nodes, which helps spot structural surprises: an export that suddenly has zero text nodes, or one that gained a hundred attributes after a schema change, tells you something the raw file does not make obvious.
Large files and privacy
Validation happens in your browser, so a document you check here never leaves the machine. That also means the same 2 MB input cap as the formatter: beyond that, the tab can run out of memory before it finishes. Oversized input is refused with the size and the limit instead of being parsed. For hundred-megabyte files, use xmllint or a streaming parser on the command line; a browser tab is the wrong tool for that job.
Frequently asked questions
Does this XML validator check XSD or DTD schemas?
No. It checks well-formedness — the XML syntax and structure — not conformance to a schema. Schema validation requires the XSD or DTD document, and this tool deliberately does not fetch or upload schemas.
What does well-formed XML mean?
Well-formed XML follows the syntax rules of the XML specification: exactly one root element, correctly nested and closed tags, quoted attribute values, unique attribute names, legal entity references and no text outside the root. A document can be well-formed and still be invalid for a particular schema.
Why does XML produced by another application fail validation?
The most common reasons are a raw ampersand in a value pasted from a spreadsheet or database, an unquoted attribute added by a template, or a document assembled by string concatenation that leaves a tag unclosed. The reported line and column point at the first place the parser could no longer make sense of the document.
Can it validate large XML files?
Validation is capped at 2 MB (2,097,152 bytes) of input, the same limit as the formatter. Larger documents are refused with a message rather than risking an unresponsive tab. Use xmllint or a streaming parser for big files.
Is my XML uploaded when I validate it?
No. Validation runs entirely in your browser. Nothing is sent to a server, and the site stores no copy of the document.
Does it check namespaces?
It checks the syntax of prefixed names such as <soap:Envelope>, but it does not verify that the prefix is declared or resolve namespace URIs. Namespace-aware validation is a schema-level concern and needs a dedicated validator.
Can I validate several documents at once?
The editor handles one document per run. For batch checks, xmllint in a shell loop or an XML plugin in your IDE is the better fit.
Related XML tools
XML Formatter
The main guide: pretty-print XML with 2/4-space or tab indentation.
Open →XML Formatter Online
Format XML online in any browser — no install and no upload.
Open →XML Minifier
Strip whitespace and indentation to shrink XML files.
Open →About
Who runs this site and how the tools are built and tested.
Open →