Skip to content
ToolZone

XML Validator

Check whether an XML document is well-formed, meaning its tags are properly opened, closed, and nested according to standard XML syntax rules.

Runs in your browser. Nothing you enter or upload leaves your device.

XML

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the XML Validator

The XML Validator checks XML for well-formedness: matched tags, proper nesting, a single root element, quoted attributes, and valid entities. Errors show the line and column with the surrounding code, and valid documents can be formatted with indentation and downloaded.

How it works

Each time the input changes, it is parsed with the browser's DOMParser using the XML content type. XML parsers are strict: they stop at the first error instead of guessing, as HTML parsers do. If the result contains a parser error, the first line of its message is shown; otherwise you see "Valid XML".

The message comes from your browser, so wording differs between Chrome, Firefox, and Safari, but it typically names the problem and gives a line and column, which the tool uses to show the offending line. The check covers syntax only. A DOCTYPE or schema reference is not used to validate element names or structure.

How to use

  1. 1

    Paste your XML into the box, or click Open file.

  2. 2

    Read the result: well-formed, or an error with its location.

  3. 3

    Fix the highlighted line, then click Format to tidy the document.

Worked examples

Well-formed

A small document.

Input
<root><item>value</item></root>
Result
Valid XML

Mismatched tag

A closing tag that does not match.

Input
<root><item>value</itm></root>
Result
An error naming the mismatched tag, with a line and column number.

Unescaped ampersand

A company name in text content.

Input
<name>Smith & Sons</name>
Result
An error about the & character.

In XML, a literal & must be written as &amp;.

Limitations
Checks well-formedness only, not DTD or XSD validity. Only the first error is reported, and whether a line and column appear depends on your browser. Formatting trims whitespace around text, so it isn't suitable for documents where that whitespace matters.
Assumptions
Input is a complete XML document with one root element.
Privacy
The XML is parsed in your browser and not sent to a server.

Frequently asked questions

What does well-formed mean for XML?+

It means the document follows XML syntax rules: one root element, every tag closed, proper nesting, quoted attributes, and escaped special characters.

Is this the same as schema validation?+

No. It checks syntax only. Validating against an XSD or DTD is a separate check.

Why does the error message look different in another browser?+

The message comes from the browser's built-in XML parser, and each browser words its errors differently.

Can I validate SVG or RSS files?+

Yes. Both are XML, so paste their source to check for well-formedness.

Related tools