Text Tools

XML Validator

Validate XML syntax and check for well-formedness.

Status

Invalid

DOMParser is not defined

Paste any XML document. The validator checks for syntax errors and well-formedness. Valid XML documents will display element count.

What is the XML Validator?

XML validation is the process of checking whether an XML document conforms to its syntactic rules: every opening tag must have a matching closing tag, tags must be properly nested, attribute values must be quoted, and special characters must be escaped. A validator parses your XML and reports whether it is "well-formed" (structurally correct) and optionally whether it matches an expected schema (like XSD).

How it works

The validator reads your XML text and applies parsing rules: it checks that the declaration (if present) is valid, confirms each opening tag has a closing tag, verifies nesting order, validates attribute syntax, and scans for unescaped special characters. When an error is found, it stops and reports the line number, column position, and description of the problem so you can fix it.

Examples

InputResultNotes
<root><item>Valid</item></root>Valid XML. No errors found.Properly opened/closed tags in correct nesting order.
<root><item>Unclosed tag</root>Error: Line 1, Column 22. Closing tag 'root' does not match opening tag 'item'.Tag mismatch—'item' opens but 'root' closes first.
<root><item name="Test">Content</item></root>Valid XML. No errors found.Attributes must be quoted; this example is correct.

How to use the XML Validator

  1. Paste or type your XML code into the validator input box
  2. Click 'Validate' or let the tool scan automatically as you type
  3. Read the error message if one appears—note the line and column number
  4. Scroll to that location in your code and fix the issue (add missing closing tag, remove duplicate tag, escape special character, etc.)
  5. Paste the corrected XML back and validate again
  6. Once 'Valid XML' appears with no errors, your code is ready to use

Benefits

  • Catch XML errors before parsing fails in your application or database
  • See exact line and column numbers so you find bugs instantly instead of guessing
  • Works offline and free—no upload limits or login required
  • Supports all standard XML declarations, attributes, CDATA sections, and comments
  • Helps you learn XML syntax by showing what makes a file malformed

Tips & common mistakes

Common mistakes

  • Forgetting to close tags: <item>content without closing tag is invalid
  • Mixing tag order: <parent><child></parent></child> nests incorrectly
  • Using unescaped special characters: use &lt; for <, &amp; for &, &quot; for " inside text or attributes
  • Omitting the XML declaration on first line when expected by parsers

Tips

  • If you have a large XML file, paste it in sections to find errors faster
  • Check attribute values are enclosed in straight double quotes, not smart quotes from word processors
  • Use proper indentation in your editor to visually spot nesting problems before validating
  • Keep a copy of your XML before fixing it in case you need to compare what changed

Frequently asked questions

What is the difference between 'well-formed' and 'valid' XML?

Well-formed XML follows all syntax rules (proper nesting, closed tags, escaped characters). Valid XML also matches a schema (XSD) or DTD. This tool checks well-formedness; schema validation requires a separate schema file.

Can I validate XML with a schema or DTD?

This validator checks basic well-formedness. To validate against an XSD schema, you'll need a schema-aware tool or server-side parser that can load and compare your schema alongside your XML.

Why does my XML fail with 'special character' errors?

Characters like <, >, &, ", and ' must be escaped inside text or attributes: use &lt; &gt; &amp; &quot; &apos; or wrap text in CDATA sections like <![CDATA[text]]>.

Does the tool accept XML with namespaces?

Yes. Namespaces (like <root xmlns="http://example.com">) are valid as long as prefixes are declared and used consistently throughout.

What if the XML declaration is missing?

XML without a declaration (<?xml version="1.0"?> on line 1) is still valid if the root element is present and well-formed, but some parsers expect the declaration.

Can I validate XML from a URL or file upload?

This tool works with pasted text. For files, paste the XML content directly or use browser file APIs if the tool supports it. Check for a file upload button on the page.

Related tools

FreeTooz Editorial Team · Last reviewed July 2026

Reviewed for accuracy. Results are estimates for general information and are not professional (medical, financial or legal) advice.