XML Validator — XSD (XML Schema)
Validates an XML string or file against the specified XSD schema. Well-formedness is checked first, then the document is validated against the XML Schema, reporting fatal errors, errors and warnings.
Result
XML validation explained
Well-formed versus valid
An XML document is well-formed when it respects the syntax of XML itself: a single root element, every start tag has a matching end tag, elements are properly nested, attribute values are quoted, special characters (<, &) are escaped, and names are legal. A document that is not well-formed is not XML at all and no parser will read it. This check is performed instantly in your browser and reports the line and column of the first problem.
A document is valid when, in addition to being well-formed, it conforms to a schema that describes which elements and attributes are allowed, in which order, how many times, and with which data types. This tool validates against XSD (XML Schema Definition, the W3C XML Schema language). Validation reports fatal errors (the document cannot be processed), errors (constraint violations) and warnings.
What is an XSD?
An XML Schema is itself an XML document, written in the http://www.w3.org/2001/XMLSchema namespace (usually prefixed xs: or xsd:). It declares:
- Elements (
<xs:element name="…" type="…"/>) and attributes (<xs:attribute name="…" use="required"/>). - Simple types: built-in types such as
xs:string,xs:integer,xs:decimal,xs:boolean,xs:date,xs:dateTime, and user-defined restrictions (patterns, enumerations, min/max values, lengths). - Complex types: content models built with
xs:sequence(ordered),xs:choice(one of) andxs:all(any order), withminOccurs/maxOccurscardinalities. - A target namespace (
targetNamespace="…") that the instance document must use, or none (a "no-namespace" schema).
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="purchaseOrder">
<xs:complexType>
<xs:sequence>
<xs:element name="shipTo" type="Address"/>
<xs:element name="item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="productName" type="xs:string"/>
<xs:element name="quantity" type="xs:positiveInteger"/>
<xs:element name="price" type="xs:decimal"/>
</xs:sequence>
<xs:attribute name="partNum" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="orderDate" type="xs:date"/>
</xs:complexType>
</xs:element>
<xs:complexType name="Address">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
How the schema is located
You can either paste (or upload) the XSD in the second box, or let the document point to it. XML documents reference their schema with attributes from the http://www.w3.org/2001/XMLSchema-instance namespace, conventionally prefixed xsi::
xsi:noNamespaceSchemaLocation="https://example.com/order.xsd"— for documents without a namespace.xsi:schemaLocation="http://example.com/ns https://example.com/order.xsd"— pairs of namespace URI and schema URL, separated by whitespace. Several pairs can be listed.
When no XSD is pasted, the validator reads these attributes and downloads the schema from the given http(s) URL (relative paths cannot be resolved because your document only exists in the browser). A pasted XSD always takes precedence over the referenced location.
Reading the results
| Level | Meaning | Example |
|---|---|---|
| error | The document violates the schema, or is not well-formed (fatal). | Element 'quantity': '-3' is not a valid value of the atomic type 'xs:positiveInteger'. |
| warning | Something suspicious that does not make the document invalid. | Failed to locate an imported schema; skipping the validation of that namespace. |
Typical messages: "This element is not expected. Expected is ( … )" means the sequence order or cardinality is wrong; "The attribute 'x' is required but missing"; "No matching global declaration available for the validation root" means the root element name or its namespace does not match the schema's target namespace (check xmlns and elementFormDefault).
Privacy note
Well-formedness is checked entirely in your browser. XSD validation itself requires a schema processor that browsers do not provide, so the XML and XSD are sent to a small server-side helper (api/xml-validate.php) built on libxml2. The data is processed in memory for the duration of the request and is neither stored nor logged. Requests are limited to 5 MB and referenced schemas are fetched only over http/https (2 MB, 10 seconds).