XML Validator, Check Well-Formed XML Online, Free
Check whether XML is well-formed in your browser. Errors give the line and column reported by the parser and show the offending line with a caret. Nothing is uploaded.
0 characters, 0 bytes
0 characters, 0 bytes
About the XML Validator
The XML Validator checks whether a document is well-formed XML and, if it is not, tells you where the first problem is. Paste XML into the box and the answer appears as you type: either Valid XML with the name of the root element and the number of elements, or an error with the line and column reported by the parser and the offending line shown with a caret under the position.
Your XML never leaves your device. The check runs in the XML parser built into your browser, so nothing is uploaded, logged or stored. You can validate configuration files, sitemaps, RSS feeds and API payloads that contain private data without sending them to a server.
How to use it
Steps
- Paste or type XML into XML. The page opens in Validate mode.
- Read the result under the output box. A valid document shows its root element and element count.
- If there is an error, look at the line and column in the message and at the caret under the offending line, fix it, and the result updates at once.
- Switch to Format to indent the document or Minify to compact it once it is valid.
What well-formed means
XML 1.0 defines a small set of syntax rules, and a document that follows all of them is well-formed. There must be exactly one root element. Every start tag needs a matching end tag, or the element must be self-closing like <br/>, and elements must close in the reverse order they opened. Attribute values must be quoted, and the same attribute cannot appear twice on one element. The characters < and & must be escaped as < and & in text, and names are case-sensitive, so <Item> cannot be closed by </item>.
Common errors
Typical messages
- Mismatched or unexpected close tag: an element was closed in the wrong order or never opened.
- Unquoted attribute value:
attr=xmust be writtenattr="x". - Only one root: two top-level elements, often after pasting two documents together.
- Undefined entity:
and other HTML entities do not exist in XML; use . - Unexpected end: the document stops before every element is closed.
Well-formed is not the same as schema-valid
A document can be well-formed and still not match what an application expects, for example a required element might be missing. That second check needs a DTD or an XML Schema, which this tool does not load. What it does guarantee is that any XML parser will read the document. The wording of messages and the exact column differ between browsers, because each uses its own parser.
Related tools
The full XML Formatter indents or minifies the document once it is valid. For JSON, the JSON Formatter validates with line and column errors in the same way, and the HTML Formatter tidies HTML, which follows looser rules than XML.
Open-source credits
- Validation uses the browser's built-in
DOMParserinterface from the DOM Parsing and Serialization specification, which applies the well-formedness rules of Extensible Markup Language (XML) 1.0 (W3C Recommendation). - The code that reads the error position and writes formatted output is written for this site; the tool uses no third-party library.