An XML validator checks your XML document for well-formedness — correct syntax, proper tag nesting, balanced elements, and valid structure. Paste XML below to get an instant VALID/INVALID verdict with specific error locations, document statistics, and an element tree view for valid documents.
Document Checks
Element Tree
XML Well-Formedness Rules
- Single root element required
- All tags must be properly closed:
<tag></tag>or<tag/> - Tags must be properly nested (no overlapping)
- Attribute values must be quoted
- Tag names are case-sensitive
- Special characters must be escaped:
& < > " ' - Comments:
<!-- comment -->(no double dashes inside) - No attributes with the same name on one element
How to Use the XML Validator
This XML validator uses the browser's DOMParser API to check XML well-formedness — the same parser used when processing XML in web applications. Paste your XML and get immediate feedback on syntax errors, document structure, and element hierarchy.
Step 1: Paste Your XML
Paste any XML content into the textarea — configuration files, API responses, SOAP messages, SVG, RSS feeds, or any other XML format. The validator accepts any text that claims to be XML, regardless of schema or DTD.
Step 2: Check Validation Results
If the XML is well-formed, you'll see a VALID badge with document statistics (element count, max depth, attribute count, namespaces). The element tree shows the hierarchy of your document up to 5 levels deep. If errors are found, the exact error message from the XML parser is shown — these messages typically include the line and column number of the problem.
Common XML Errors
The most frequent XML errors are: unclosed tags (forgot the closing </tag>), mismatched case (XML is case-sensitive: <Item> and <item> are different), unescaped special characters (use & instead of &), and unquoted attribute values.
XML vs JSON
XML and JSON are both data exchange formats. XML adds explicit structure through elements, attributes, and namespaces, making it better suited for document-centric data, mixed content, and scenarios requiring comments or processing instructions. JSON is more compact for simple data structures. For API design, JSON is now more common; for configuration files and enterprise integrations, XML remains widely used.
FAQ
What is XML well-formedness?
A well-formed XML document follows all syntax rules: a single root element, properly closed tags, correctly quoted attributes, no illegal characters, and properly nested elements. Well-formedness is required before XML can be parsed by any application.
How does this XML validator work?
This tool uses the browser's built-in DOMParser with 'text/xml' parsing mode. If the document is not well-formed, DOMParser returns a document containing a 'parsererror' element with an error description instead of the actual content.
What's the difference between well-formed and valid XML?
Well-formed XML follows syntax rules (correct tags, nesting, etc.). Valid XML additionally conforms to a specific schema or DTD definition. This tool checks well-formedness only — schema validation would require loading the DTD or XSD definition.
Is my XML data sent to a server?
No. All validation runs in your browser using the built-in DOMParser API. Your XML data is never transmitted anywhere — it stays completely private on your device.
Is this tool free?
Yes, completely free. Paste any XML and get instant validation with error details. No account or signup required.
Why do I need an XML declaration?
The XML declaration (<?xml version='1.0' encoding='UTF-8'?>) is technically optional for UTF-8 encoded XML but strongly recommended. It declares the XML version and character encoding, preventing parsing ambiguity in different environments.