HomeValidatorsDataXML Validator

XML Validator

Data

Paste any XML document and instantly check if it is well-formed. See the exact parse error and position — runs entirely in your browser, no signup needed.

What is a XML?

An XML Validator checks whether an XML document is well-formed — meaning it satisfies the strict syntax rules defined by the W3C XML 1.0 specification. XML (eXtensible Markup Language) is used for configuration files, data exchange formats (SOAP, RSS, SVG, AndroidManifest.xml), API responses, and document storage. Unlike HTML, which browsers parse leniently, XML is unforgiving: a single unclosed tag or unescaped & character causes the entire document to fail parsing.

This tool uses the browser's built-in DOMParser with the 'text/xml' MIME type — the same parser used by browsers when they process RSS feeds or SVG files. The result is therefore identical to what any standards-compliant XML parser will produce. If the parser inserts a <parsererror> element into the result tree (the standard mechanism for signalling a well-formedness error), the tool extracts and displays that error verbatim, including the line and character position.

Well-formedness covers structural syntax only. This tool does not validate against a DTD or XSD schema — it confirms the XML is parseable, not that it conforms to a specific data structure. For schema validation, you need a separate tool with the schema definition.

Validation runs entirely in your browser — no XML is transmitted or stored. Safe to use with configuration files, API responses, or any document containing internal data. See the JSON Validator for equivalent checks on JSON documents.

How to use this XML calculator

  1. Open the XML Validator on this page.
  2. Paste your XML document into the XML Input field.
  3. The result badge updates instantly. A green Valid badge confirms the document is well-formed.
  4. If the badge shows Invalid, read the error detail — it includes the line and character position of the parse failure.
  5. Navigate to that position in your XML, fix the structural error (missing closing tag, unescaped character, mismatched nesting), and paste the corrected XML back.
  6. Repeat until the Valid badge appears.

Formula & Methodology

The validator uses the browser's built-in DOMParser:

js const parser = new DOMParser(); const doc = parser.parseFromString(xml, 'text/xml'); const errorNode = doc.querySelector('parsererror'); 

If parsererror is present, the XML is not well-formed. The error text from that node is the browser's native parse error, including position information.

Valid example:
xml <root>   <item id="1">Hello</item> </root> 
Result: Well-formed. Root element <root>, 1 child element.

Invalid example (unclosed tag):
xml <root>   <item>Hello </root> 
Result: Not well-formed — <item> is not closed. Error at line 3, near </root>.
Frequently Asked Questions
What is an XML Validator?
An XML Validator checks whether an XML document is well-formed — meaning it follows the syntax rules defined by the W3C XML specification. A well-formed XML document has a single root element, all tags are properly closed, attribute values are quoted, and no illegal characters appear in the content. This tool uses the browser's built-in XML parser, so the result is identical to what any standards-compliant parser will produce.
What does well-formed XML mean?
A well-formed XML document satisfies these rules: there is exactly one root element that contains all other elements, every opening tag has a matching closing tag (or is self-closed with `/>` for empty elements), tags are properly nested (no overlapping), attribute values are enclosed in single or double quotes, and the `<`, `>`, and `&` characters in text content are escaped as `&lt;`, `&gt;`, and `&amp;`. XML is far stricter than HTML in this regard.
What is the difference between well-formed and valid XML?
Well-formed means the document follows XML syntax rules. Valid means the document also conforms to a schema — either a DTD or an XML Schema (XSD) — that specifies which elements and attributes are permitted and in what structure. This tool checks well-formedness only. Schema validation requires a separate tool with the schema definition.
Does the XML Validator check against a schema?
No. This tool performs well-formedness checking only — it does not validate against DTD, XSD, or RelaxNG schemas. If you need to check that your XML conforms to a specific schema (e.g. a SOAP envelope or a specific API response structure), you need a schema-aware validator. This tool catches structural errors: unclosed tags, bad attribute syntax, illegal characters.
What are the most common XML errors?
The most frequent XML errors are: unclosed tags (forgetting the `</tag>` closing), improperly nested tags (opening A, opening B, closing A before closing B), unquoted attribute values, the use of `<`, `>`, or `&` directly in text content instead of their escaped forms (`&lt;`, `&gt;`, `&amp;`), and multiple root elements. The parser error message includes the position (line and character) where the problem was detected.
Can I validate minified or single-line XML?
Yes. The parser does not care about whitespace or line breaks — minified and formatted XML are treated identically. Paste your XML in any form.
Is the XML I paste stored anywhere?
No. The validation uses the browser's built-in `DOMParser`, which runs entirely in your browser process. Nothing is sent to a server. This makes it safe to validate XML containing internal data, API credentials in attributes, or any sensitive content.
What is the difference between XML and HTML?
HTML is designed to be forgiving — browsers silently fix unclosed tags, accept unquoted attributes, and handle overlapping tags. XML is strict: any syntax error causes the parser to stop and report a failure. XHTML is HTML written to follow XML rules. This validator uses the strict XML parser, not the lenient HTML parser.
How do I fix a 'multiple root elements' XML error?
Standard XML requires exactly one root element. If your document has two or more elements at the top level, wrap them in a single container element. For example, if you have `<a/>` and `<b/>` at the top level, write `<root><a/><b/></root>`. This is a common issue when concatenating XML fragments.
Why does my XML with a DOCTYPE fail validation?
The browser's DOMParser in 'text/xml' mode may flag an error if the DOCTYPE references an external DTD that cannot be loaded. If your XML has a DOCTYPE declaration, try removing it before validating — the well-formedness check does not require the DTD to be present.
Can this tool validate SOAP messages or API responses?
Yes — SOAP messages and API responses are XML and must be well-formed. Paste the XML body and this tool will confirm it parses correctly. Schema validation (confirming the SOAP envelope structure is correct) is a separate concern not covered by this tool.