FormatterHQ

XML Validator

Check whether your XML is well-formed before it breaks a parser. Errors point to the exact line and column, and a valid document shows its root element and element count.

Input XML
Output XML
Ready.

How to use the XML Validator

  1. Paste your XML, drop a file on the editor, use Upload file or Load URL, or click Sample.
  2. Click Validate (it also runs automatically while Auto update is on).
  3. Read the status bar: either a success line such as Valid XML ✓ — root <order>, 6 elements or an error with line and column.
  4. Fix the reported spot in the editor; the check reruns as you type. Use Format to get the corrected document indented.

What this XML validator checks

This XML validator tests whether a document is well-formed: whether it follows the syntax rules that every XML parser enforces. A file that fails this check will be rejected by any parser, whether it is a Java SAX parser, .NET's XmlDocument, Python's ElementTree or a browser. When the document passes, the status bar confirms it and names the root element and the number of elements, and the output panel shows it neatly indented.

Well-formed versus schema-valid

It is worth being precise, because the word "valid" means two things in XML:

  • Well-formed – the syntax is correct. This is what the tool checks.
  • Valid against a schema – the document also matches an XSD, DTD or RELAX NG definition: the right elements, in the right order, with the right data types. This tool does not load or apply schemas, and a <!DOCTYPE> line is accepted but not used to check the content.

Well-formedness is the first gate. If you are debugging an integration that rejects your file, confirm it here first; if it passes, the problem is in the schema or the content rules of the receiving system.

The rules, with the errors you get when they break

RuleBreaks itReported as
Every start tag has a matching end tag<a><b>x</a>Expected closing tag 'b' … instead of closing tag 'a'
Names are case-sensitive<Item></item>Expected closing tag 'Item' …
Exactly one root element<a/><b/>Multiple possible root nodes found
Attribute values are quoted<b id=1>Attribute 'id' is without value
No attributes without a value<input checked/>boolean attribute 'checked' is not allowed
No repeated attributes<b x="1" x="2"/>Attribute 'x' is repeated
Ampersands in text are escaped<b>Tom & Jerry</b>char '&' is not expected
Names cannot start with a digit<1st/>Tag '1st' is an invalid name
The file is complete<a><b>ok</b>Unclosed tag 'a'

For a mismatched closing tag, the message also tells you where the unclosed element was opened, for example (opened in line 2, col 3), which saves a lot of scrolling in long files.

Example

This order looks fine at first glance:

<order id="1042">
  <customer>Ava Martinez</customer>
  <note>Leave with R&D reception</note>
</order>

The validator stops at line 3 because of the bare & in "R&D". Change it to R&amp;D, or wrap the text in <![CDATA[ ... ]]>, and the status bar reports Valid XML ✓ — root <order>, 3 elements.

Limits worth knowing

The check is a fast syntax pass, not a full XML processor. A few problems a strict parser would also flag are not reported here:

  • Namespace prefixes that were never declared, such as <soap:Envelope> without an xmlns:soap attribute.
  • Entity references that XML does not define, such as &nbsp;, which is an HTML entity. In XML use the numeric reference &#xA0; instead.
  • A raw < or & inside an attribute value. Escape them as &lt; and &amp;.
  • A double hyphen inside a comment, such as <!-- a -- b -->, and the sequence ]]> in ordinary text.
  • Control characters, and character references to characters XML does not allow, such as &#0;.
  • An XML declaration that is not at the very start of the document, for example inside the root element.

If a document passes here but your application still rejects it, look for these first. The XML escape tool converts special characters in a snippet for you.

Related tools

To tidy the document after fixing it, use the XML formatter. To query the validated file, try the XPath tester.

Privacy

Validation happens in your browser, so the XML is not uploaded. Only Load URL, which fetches through our server, and Save & Share, which stores the input to create a link, send data to us.

Frequently asked questions

Can I validate XML against an XSD schema here?
No. The tool checks well-formedness only. For XSD validation use a schema-aware tool such as xmllint --schema, your IDE, or the XML library of your programming language.
Why is my HTML reported as invalid XML?
HTML allows things XML does not: unclosed tags like
, attributes without values like checked, unquoted attributes and entities like  . Write
, checked="checked" and   to make the markup well-formed XML.
Does a leading BOM or blank line cause an error?
No. A UTF-8 byte order mark and whitespace before the first tag are ignored, so files saved by Windows editors validate normally.
What does "Multiple possible root nodes found" mean?
XML requires a single element that contains everything else. The message appears when you paste two documents together or a list of sibling elements. Wrap them in one parent element, for example ….
Is the line number counted from the start of my paste?
Yes. Line 1 is the first line in the editor, including any blank lines above the XML declaration, so you can jump straight to the reported position.

Last updated October 3, 2026

Related tools

Credit Card Validator Check credit card numbers with the Luhn algorithm, detect Visa, Mastercard, Amex and more, and verify length. Runs 100% locally. CSS Validator Validate CSS online: find unclosed braces, missing semicolons and other syntax errors. Email Address Validator Check email address syntax in bulk and flag typos in popular domains, disposable providers, role accounts and duplicates. HTML Validator Validate HTML markup online and find unclosed, mismatched or malformed tags. IBAN Validator Validate IBANs for 80+ countries with the MOD-97 checksum and country length rules, and see bank code and account parts. ISBN Validator & Converter Validate ISBN-10 and ISBN-13 check digits and convert between the two formats, one or many at a time. XML Viewer View XML as a collapsible tree alongside formatted text. Inspect elements, attributes and values in any XML document. XML XSL Transform Apply an XSLT stylesheet to XML online and preview the result. Produce HTML, XML or text output from any XML document. XPath Tester Test XPath expressions online against your XML. See matched nodes, attributes, strings, numbers or booleans instantly. MXML Viewer View and format Adobe Flex / Apache Royale MXML files online with a component tree and neatly indented markup. OPML Viewer View OPML subscription lists and outlines as a clickable, nested list. Inspect feed URLs exported from any RSS reader. RSS Feed Viewer View RSS and Atom feeds as readable articles. Paste feed XML to preview titles, links, dates and summaries.