Developer Tools · Validators

XML validator and formatter.

Check that XML is well-formed, find the line and column of the first error, then pretty-print, minify or convert it to JSON. This checks well-formedness only, not XSD or DTD validity.

Advertisement

Your XML

Result

Paste XML and press Check well-formedness.

What "well-formed" means

The XML 1.0 specification defines a well-formed document as one that matches the document grammar and meets every well-formedness constraint. In practice that means one root element, start and end tags that match and nest properly (names are case-sensitive), quoted attribute values, no repeated attribute name in one tag, and no bare < or & in text. The five predefined entities are &lt;, &gt;, &amp;, &apos; and &quot;.

What this tool does not check

Well-formedness only. The check uses your browser's built-in XML parser (DOMParser, application/xml). It does not validate against an XSD schema or a DTD, so a document can pass here and still be invalid for your application. Browsers also do not fetch external DTDs, and an entity that is not one of the five predefined ones and is declared only in an external file is reported as an error. Error wording and the exact position can differ between Chrome, Firefox and Safari, and the parser reports only the first error.

Formatting and JSON conversion

Pretty-print and minify only change whitespace between elements. Elements with mixed text and child elements, and elements marked xml:space="preserve", are left as written so the data does not change. Minify also removes comments. XML to JSON uses a common convention (attributes become "@name", text next to attributes or child elements becomes "#text", repeated elements become an array, empty elements become null). XML and JSON do not map one-to-one, so element order between different names, comments and mixed content are not preserved. Formatting and conversion run only on input that passed the well-formedness check.

Sources: W3C, Extensible Markup Language (XML) 1.0, section 2.1 (well-formed documents) and section 4.6 (predefined entities); MDN, DOMParser. Everything runs in your browser. Nothing you paste is stored or sent.

Advertisement
Advertisement
Listening…