Check whether your XML documents are well-formed against W3C standards, identify parsing errors with exact line and column numbers, inspect document structure metrics, and format valid XML.
Follow these quick steps to check whether your XML documents are well-formed and diagnose syntax errors:
Paste XML code into the editor or upload an .xml or .txt file from your device.
Click the Validate XML button (or press Ctrl+Enter) to execute native browser parsing.
Review the well-formedness status, line/column coordinates, error snippet, and document structure metrics.
Optionally format the valid XML with clean indentation or download it as validated.xml.
XML validators evaluate documents at different levels of compliance:
| Criteria | Well-Formed XML (Checked by this Tool) | Schema-Valid XML (XSD / DTD Validation) |
|---|---|---|
| Definition | Complies with universal W3C XML 1.0 syntax rules. | Conforms to a specific external XSD or DTD schema definition. |
| Root Element | Must possess exactly one single root element. | Root element type and attributes must match schema declarations. |
| Tag Matching | Every opening tag must have an exact case-matching closing tag. | Tags must appear in the exact order, sequence, and multiplicity required. |
| Attribute Syntax | All attribute values must be enclosed in quotes (name="val"). |
Attribute data types (e.g., integer, boolean, ISO date) are enforced. |
| Parser Requirement | Validated natively in any modern browser without external schemas. | Requires dedicated schema compiler and access to schema URI files. |
Here are the most frequent syntax mistakes encountered when working with XML and how to correct them:
<catalog>
<book id="101">
<title>XML Fundamentals</title>
</book-item> <-- Tag name mismatch
</catalog>
<catalog>
<book id="101">
<title>XML Fundamentals</title>
</book>
</catalog>
<item id="1">Apples</item>
<item id="2">Oranges</item> <-- No single root
<items>
<item id="1">Apples</item>
<item id="2">Oranges</item>
</items>
<product sku=10492 inStock=true> <-- Missing quotes
<name>Headphones</name>
</product>
<product sku="10492" inStock="true">
<name>Headphones</name>
</product>
<note>Price is < $50 & shipping is free</note> <-- Unescaped < and &
<note>Price is < $50 & shipping is free</note>
<!-- OR use CDATA: <![CDATA[Price is < $50 & shipping is free]]> -->
Find answers to common questions about XML syntax validation, well-formedness rules, and error diagnosis:
xmlns:prefix="URI") prevent element naming collisions when combining XML vocabularies from different domains (e.g., SOAP envelopes, SVG graphics, and XHTML). Our validator fully supports namespace declarations and prefixed elements.
<![CDATA[ ... ]]>) tells the XML parser that the text inside is character data rather than XML markup. It allows you to embed code snippets, SQL queries, HTML tags, or symbols without escaping special characters.
Explore our suite of complimentary formatting, validation, and encoding tools: