XML validator: check XML syntax, free and private
An XML validator checks that a document follows the syntax rules of XML. To validate XML free and privately, paste it into XML Input or click Upload XML File. The badge above the editor changes to Well-formed XML or Not well-formed XML as you type, and each error shows its line and column. The check uses your browser's own XML parser, so nothing is uploaded; you can confirm that in the Network tab of DevTools.
Well-formed means exactly one root element, tags closed and nested correctly, matching tag names, quoted attribute values and escaped < and & characters. This tool checks well-formedness only. It does not check a document against a DTD or an XML Schema (XSD), and it says so in a note when your file refers to one.
For common slips, such as unquoted attributes or a bare ampersand, it offers a one-click fix. When the XML is clean, tidy it with the XML formatter or turn it into JSON with the XML to JSON converter.
Table of Use: what the validator says about common XML
| You paste | Result (Chrome's wording) | Help offered |
|---|---|---|
| <root><item id="1">A</item></root> | Well-formed XML | Document summary: root element, 2 elements, 1 attribute, maximum depth 2. A note says the optional XML declaration is missing. |
| <root><a></root> | Not well-formed: Opening and ending tag mismatch: a line 1 and root. (line 1, column 17) | How to fix it: close elements in the reverse order they were opened. |
| <Item>value</item> | Not well-formed: Opening and ending tag mismatch: Item line 1 and item. (line 1, column 19) | How to fix it: tag names are case-sensitive. |
| <item id=123>value</item> | Not well-formed: AttValue: " or ' expected. (line 1, column 10) | Automatic fix: put quotes around 1 attribute value. |
| <item>Tom & Jerry</item> | Not well-formed: xmlParseEntityRef: no name. (line 1, column 12) | Automatic fix: escape 1 bare & character as &. |
| <root><p> </p></root> | Not well-formed: Entity 'nbsp' not defined. (line 1, column 16) | Automatic fix: replace 1 HTML entity with a numeric character reference. |
| <a/><b/> | Not well-formed: Extra content at the end of the document. (line 1, column 5) | How to fix it: wrap everything in a single root element. |
| <root><a>1 | Not well-formed: Premature end of data in tag a line 1. (line 1, column 11) | How to fix it: add the missing closing tag. |
Parser messages come from your browser, so Firefox or Safari can word the same error differently. Feeds and sitemaps are XML too: if you build one with the sitemap generator, check it here before you submit it. A JSON counterpart is the JSON validator.
Features
- Checks as you type. The Well-formed XML or Not well-formed XML badge updates with every edit.
- Precise errors. The Error box gives the parser's message, the line and column, and the offending line with a caret. Go to line selects it in the editor.
- How to fix it. A plain-English hint for the usual causes: mismatched tags, a document cut short, extra root elements, unquoted attributes, bare ampersands, undefined entities and more.
- Apply fix. Quotes unquoted attribute values, gives value-less attributes a value, escapes bare ampersands and replaces common HTML entities. Comments, CDATA, processing instructions and the DOCTYPE are never changed.
- Document summary. For well-formed XML: Root element, Elements, Attributes, Maximum depth, Comments, CDATA sections, Processing instructions and Namespaces, with the namespace URIs listed.
- Notes. Flags a missing XML declaration, a DOCTYPE, or an XSD reference, and says that DTD and schema rules are not checked.
- Upload XML File. Accepts .xml, .xsd, .xsl, .xslt, .svg, .rss, .atom, .plist and .config files, reading the encoding from the byte-order mark or the XML declaration.
- Show line numbers, Copy XML or Copy Fixed XML, Clear and a Common XML Errors cheat sheet under the editor.
It tells you what is wrong; it does not reformat. Use the XML formatter for indentation, and for markup that is HTML rather than XML try the HTML beautifier.
How to validate XML, step by step
- Paste or type your XML into XML Input, or click Upload XML File and choose a file.
- Read the badge: Well-formed XML or Not well-formed XML.
- For an error, read the Error box, click Go to line to jump to the position, and read How to fix it.
- If Automatic fix available appears, check the listed changes and click Apply fix. The editor is replaced with the repaired XML and the badge updates.
- When the XML is well-formed, read the Document summary and any Notes.
- Click Copy XML (or Copy Fixed XML), open the XML formatter from the link beside it, or click Clear to start over.
Who can use it
- Developers and integrators debugging API payloads, SOAP messages and .config or .plist files that a parser rejects, then comparing the fixed version with the original in the text diff tool.
- Webmasters and SEO specialists checking sitemaps and RSS or Atom feeds before search engines read them.
- Data engineers confirming a file is well-formed before converting it with the JSON to XML converter or its reverse.
- Designers whose SVG file will not open: an SVG is XML, so the error position is usually the quickest clue. Once it parses, the SVG to CSS converter can use it.
- Students learning the rules, using the Common XML Errors panel and the table above.
FAQs
What does this XML validator check?
It checks that the document is well-formed XML, using your browser's built-in XML parser: exactly one root element, every tag closed and correctly nested, tag names that match in case, quoted attribute values, no repeated attributes, escaped < and & characters, defined entities and declared namespace prefixes. It does not check the document against a DTD or an XML Schema (XSD).
What is the difference between well-formed and valid XML?
Well-formed XML follows the syntax rules in the W3C's XML specification, so any XML parser can read it. Valid XML is well-formed and also obeys a schema, either a DTD or an XSD, which lists the allowed elements, attributes, order and data types. Every valid document is well-formed, but a well-formed document is valid only against a schema. This tool checks well-formedness.
Can I validate XML against an XSD or DTD here?
No. Browsers do not apply a schema or DTD when they parse XML, so this tool cannot report schema errors. When your document has a DOCTYPE or an xsi:schemaLocation attribute, a note says that those rules were not checked and only well-formedness was. Use a schema-aware validator for that step once this tool reports Well-formed XML.
How do I fix an XML error?
Read the Error box: it gives the parser's message, the line and column, and the offending line with a caret under the position. Click Go to line to select it in the editor, and read How to fix it for a plain-English hint. The parser reports where it noticed the problem, which can be just after the real mistake, such as the closing tag that follows a missing one.
What can the automatic fix repair?
It puts quotes around unquoted attribute values (id=123 becomes id="123"), gives value-less attributes a value (disabled becomes disabled="disabled"), escapes a bare & as &, and replaces common HTML entities such as and © with numeric references. It is offered only when the result is well-formed, and it cannot guess where a missing closing tag belongs.
Is an XML declaration required?
No. The <?xml version="1.0"?> declaration is optional in XML 1.0 when the file is UTF-8 or UTF-16. It is needed for another encoding, such as ISO-8859-1, and some tools expect it. When it is missing, the validator adds a note under Notes but still reports Well-formed XML, because the document follows the rules.
Is my XML uploaded to a server?
No. The check runs in your browser with its own XML parser, and an uploaded file is read on your device. Nothing is sent to ZipConvert. You can confirm this in the Network tab of your browser DevTools while you paste or upload: no request carries your XML. The wording of parser messages comes from your browser, so it can differ between browsers.