Friday, November 6, 2026 · Asia/KarachiFree tools · No signup · Runs in your browser

XML Validator

This XML validator checks that tags open and close in order. A note that contains a to element, both properly closed, is well-formed. An a element that closes while a b element is still open is invalid, and the message names both tags.

New

It does not apply a schema, a DTD, or a namespace rule. Matching brackets is the whole test.

How to use

  1. Paste XML.
  2. Press Check. Well-formed text says so and counts elements that opened.
  3. A mismatch names the tag that was open and the closer that was found. Reset restores the note sample.

Formula / how it works

The stack. Start tags are pushed. End tags must match the tag on top of the stack. A self-closing tag, one that ends in a slash before the greater-than, does not push. Comments and CDATA sections are skipped, so a word that looks like a tag inside them does not have to balance. The sample note opens note, opens to, closes to, closes note. Two elements opened. The status is well-formed. The broken fragment <a><b></a> tries to close a while b is on top, so the message says it expected a closer for b and found a closer for a.

Attributes. Quotes inside attributes are not checked. A missing quote can still look balanced if the angle brackets pair. That is a limit of a tag-name stack. Use this page to find a swapped closer or a tag you never closed. Use a schema tool, which this is not, when the element names have to belong to a vocabulary. The XML formatter pretty-prints. It is not this checker.

Unclosed tags. If the text ends while something is still on the stack, the status is invalid and the message names the unclosed tag. The deepest unclosed name is the one reported, which is the last one opened that never closed.

Attributes are ignored, which means a missing quote inside an attribute can still look well-formed to this checker if the tag brackets balance. That is a limit, not a bug in your file that the checker will catch. Use it to find a swapped closer, an unclosed note, or a self-closing tag you wrote with a slash. Self-closing tags do not push the stack. A comment and a CDATA section are skipped so a tag-like word inside them does not have to match.

Try the broken example on purpose once, so the message is familiar. Expected closer for b, found a closer for a, means the stack and the text disagreed. Fix by closing b before a, or by removing b if it was a typo. Then press Check again. A well-formed result is not permission to skip a schema if your project has one. It is permission to stop looking for a mismatched tag. Namespaces written as prefixes are just part of the tag name here. xmlns attributes are ignored along with every other attribute. A self-closing tag written without the slash will sit on the stack until the file ends, and the unclosed name will be that tag. Add the slash or add a real closer. Do not add a schema to fix a stack error.

Well-formed is a structural word. It means the stack emptied cleanly. It does not mean the file matches a contract, a sample, or last week’s export. Keep those checks elsewhere. Use this page when the only question is which tag was still open.

Worked examples

A note that closes

Inputs: XML: <note><to>Ada</to></note>

Leave the box as <note><to>Ada</to></note> and press Check. The status is well-formed and two elements opened.

Result: Status: well-formed Elements opened: 2 This checks matching tags only. It does not apply a schema.

A closer in the wrong order

Inputs: XML: <a><b></a>

Paste <a><b></a> and press Check. The message expected a closer for b and found a closer for a.

Result: Status: invalid Expected closer for b, found </a>

Use cases

  • Finding a swapped closer before a parser complains in a less direct way.
  • Confirming a small note is balanced.
  • Ignoring comments and CDATA while you check the real tags.
  • Seeing that a schema is out of scope.

Tips & limitations

  • A balanced result can still have a broken attribute quote.
  • Self-closing tags do not need a closer.
  • This is not the XML formatter.
  • The unclosed name is the last one still open.

FAQ

Does this validate against a schema?

No. It checks that tags open and close in order. Names are not looked up in a vocabulary.

Why did a missing attribute quote pass?

Attributes are not parsed. Only tag names and whether the tag is self-closing are used.

Are comments required to balance?

No. Comments and CDATA are skipped.

What does elements opened count?

Start tags, including self-closing ones. End tags are not added.

Will it indent the XML?

No. The formatter does that. This page returns a status.

Is the XML uploaded?

No. The stack is checked in the browser.

Runs entirely in your browser; nothing is uploaded. Check the output before you rely on it in production code, data or security decisions.