XML Validator

Check if your XML is well-formed and valid. Get instant feedback with detailed error messages and line numbers.

XML Input

Runs fully in your browser. No data sent to our servers.

How to Validate XML

1

Paste or upload XML

Enter your XML content in the input area or upload an XML file from your computer.

2

Click Validate

Press the Validate button to check your XML for syntax errors and well-formedness.

3

Review results

See instant validation results. If errors are found, you'll get detailed messages with line numbers.

4

Fix and revalidate

Correct any errors using the provided guidance, then validate again until your XML passes.

Understanding XML Validation

Well-Formed vs Valid XML

There are two levels of XML correctness that developers need to understand:

Well-Formed XML

Follows basic XML syntax rules. Every XML document must be well-formed to be processed by any XML parser. This tool checks for well-formedness.

Valid XML

Well-formed AND conforms to a specific schema (XSD or DTD). Validation ensures your XML follows a predefined structure with correct elements and data types.

XML Well-Formedness Rules

For an XML document to be well-formed, it must satisfy these rules:

  • Exactly one root element contains all content
  • Every opening tag has a matching closing tag
  • Elements are properly nested (no overlapping)
  • Tag names are case-sensitive and must match
  • Attribute values are enclosed in quotes
  • Special characters are properly escaped

Common XML Errors and How to Fix Them

Mismatched Tags

❌ Invalid:

<Name>John Smith</name>

✅ Valid:

<Name>John Smith</Name>

Fix: XML is case-sensitive. Ensure opening and closing tags match exactly.

Improper Nesting

❌ Invalid:

<b><i>Bold and italic</b></i>

✅ Valid:

<b><i>Bold and italic</i></b>

Fix: Close inner tags before outer tags. Elements cannot overlap.

Unquoted Attribute Values

❌ Invalid:

<book category=fiction>

✅ Valid:

<book category="fiction">

Fix: Always enclose attribute values in double or single quotes.

Unescaped Special Characters

❌ Invalid:

<formula>5 < 10 & 10 > 5</formula>

✅ Valid:

<formula>5 &lt; 10 &amp; 10 &gt; 5</formula>

Fix: Use XML entities: &lt; for <, &gt; for >, &amp; for &

Multiple Root Elements

❌ Invalid:

<book>...</book>
<book>...</book>

✅ Valid:

<library>
  <book>...</book>
  <book>...</book>
</library>

Fix: Wrap all content in a single root element.

XML Entity Reference

These predefined entities must be used to represent special characters in XML content:

CharacterEntityNumericDescription
<&lt;&#60;Less than (starts tags)
>&gt;&#62;Greater than (ends tags)
&&amp;&#38;Ampersand (starts entities)
"&quot;&#34;Double quote (in attributes)
'&apos;&#39;Single quote (in attributes)

Next Steps After Validation

Frequently Asked Questions

Related XML Tools