Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

XSD Validator

Check XML against an XML Schema and get every error with its line, path and a clear fix.

Developer No upload Works offline Free, no sign-up
Additional schema files (for xs:include and xs:import)

Add the files the schema includes or imports. They are matched by file name (the last part of schemaLocation), imports also by target namespace. The XML namespace schema (xml.xsd) is built in. Nothing is downloaded.

    Paste a schema file instead
    Ctrl/⌘ + Enter validates

    Next steps

    About the XSD Validator

    Paste an XML document and its XML Schema (an .xsd file) and find out whether the document follows it. Every problem is listed with its line and column, its place in the document (/orders/order[2]/@status) and an explanation — including the namespace mistakes behind most "No matching global declaration" and "This element is not expected" errors, which the tool spells out: "The schema declares <library> in the namespace urn:lib: add xmlns="urn:lib" to the root element of the document."

    The validator implements XML Schema 1.0 in your browser: all built-in types (dates, decimals, durations, QNames …) with their value rules, every facet including patterns in XML Schema's own regular-expression dialect, complex types with extension and restriction, groups, xs:all, wildcards, substitution groups, xsi:type and xsi:nil, default and fixed values, ID/IDREF and xs:key / xs:unique / xs:keyref. The schema itself is checked too, so a misspelt attribute or an <xs:element> placed directly inside <xs:complexType> is reported with its line. Generate XSD from XML writes a starter schema from a sample document.

    How to use it

    1. Paste the XML on the left and the XSD on the right, open the two files, or press Load sample (its document has five deliberate mistakes).
    2. If the schema uses <xs:include> or <xs:import> with other files, add them under Additional schema files — they are matched by file name (imports also by namespace). Nothing is downloaded.
    3. Press Validate (or Ctrl/⌘ + Enter). With Validate as I type on, documents under 1 MB are checked as you edit.
    4. Work through the list: each problem shows where it is and what is expected; Show selects it in the editor. Copy or download the report to share it.
    5. No schema yet? Paste a sample document and press Generate XSD from XML, choose a nested or flat layout, then tighten the types and occurrences it suggests.

    Examples

    A date that does not exist
    Input
    Schema: <xs:element name="placed" type="xs:date"/>
    XML:    <placed>2026-09-31</placed>
    Result
    Line 1, column 9 · /placed — Element 'placed': '2026-09-31' is not a valid value of the atomic type 'xs:date'. Use the form 2026-10-03 (year-month-day), optionally with a time zone.

    September has 30 days: values are checked against the rules of their type, not only their shape.

    The document is missing the schema's namespace
    Input
    Schema: <xs:schema … targetNamespace="urn:lib" elementFormDefault="qualified"> with <xs:element name="library"/>
    XML:    <library>…</library>
    Result
    Line 1, column 1 · /library — Element 'library': No matching global declaration available for the validation root — the schema has no top-level <xs:element name="library"> (in no namespace). The schema declares <library> in the namespace urn:lib: add xmlns="urn:lib" to the root element of the document.
    Elements in the wrong order
    Input
    Schema: <xs:sequence> with <xs:element name="title"/> then <xs:element name="author"/>
    XML:    <book><author>Asha</author><title>Notes</title></book>
    Result
    Line 1, column 7 · /book/author — Element 'author': This element is not expected. Expected is <title>. (<author> is allowed in this element, but not at this position — check the order of the elements and how often each may appear.)

    Use <xs:all> (each element once, any order) or <xs:choice maxOccurs="unbounded"> if the order should not matter.

    Common uses

    • Checking XML for e-invoicing (UBL, Peppol), banking (ISO 20022, SEPA) or customs and tax portals against the XSDs they publish, before uploading.
    • Testing SOAP request and response bodies against the schemas of a WSDL.
    • Validating configuration and data-exchange files (Maven POMs, XML sitemaps, partner feeds) in a build or a code review.
    • Writing or debugging an XSD: see exactly which declaration or facet rejects a test document, and catch mistakes in the schema itself.
    • Bootstrapping a schema for an existing XML format from a sample file.

    What is checked

    Built-in types with their lexical and value rules: xs:date rejects 2026-02-30, xs:int rejects 2147483648, xs:decimal compares 1.0 and 1 as equal for enumerations and keys, durations and dates with time zones are ordered as the specification defines. Facets: length, minLength, maxLength, pattern, enumeration, whiteSpace, the four bounds, totalDigits and fractionDigits, on restricted, list and union types.

    Structures: sequences, choices and xs:all with any minOccurs / maxOccurs, named groups and attribute groups, empty, simple, element-only and mixed content, complex-type extension and restriction, abstract types and elements, substitution groups (with block and final), xs:any and xs:anyAttribute with strict, lax and skip processing, xsi:type, xsi:nil, default and fixed values, unique IDs and IDREFs that point to them, and xs:key, xs:unique and xs:keyref with their XPath subset.

    The schema: element and attribute names from the schema-for-schemas (with "did you mean" for typos), unresolved or circular references, references to namespaces that are not imported, duplicate definitions, facets that do not apply, contradict each other or widen the range of their base type, more than one xs:ID attribute on a type, invalid patterns, default values that do not fit their type, <xs:all> misuse, and identity constraints whose unprefixed XPath names can never match a namespaced document. Two elements of the same name with different types in one content model are reported as a warning: xmllint accepts such schemas, Xerces and .NET refuse them.

    Includes, imports and namespaces

    xs:include and xs:import are resolved against the files under Additional schema files: by file name (the last part of schemaLocation, so ../common/types.xsd finds a file named types.xsd), and for imports also by targetNamespace. An included file without a targetNamespace takes the including schema's namespace ("chameleon" include). The XML namespace schema (xml:lang, xml:space, xml:base, xml:id) is built in, so <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/> works without the file. An import that cannot be found is a warning; anything the document then needs from that namespace is reported where it is used.

    The instance attributes xsi:schemaLocation and xsi:noNamespaceSchemaLocation are not followed — paste the schema they name.

    Generating a schema from XML

    Generate XSD from XML writes a schema that accepts the sample: elements that always appear in the same order become an xs:sequence (optional when missing from some instances, maxOccurs="unbounded" when repeated), others an xs:choice that may repeat; text next to child elements makes the type mixed; attributes present on every instance are use="required"; values become xs:boolean, xs:integer, xs:decimal, xs:date, xs:dateTime or xs:time when every sample value fits, otherwise xs:string (numbers with leading zeros, such as PIN codes, stay strings). Nested puts everything inside one top-level element; Flat declares each element name once at the top level and refers to it with ref. A sample cannot show every allowed variation, so review the result before relying on it.

    Limitations

    • XML Schema 1.1 (assertions, conditional type assignment, open content, xs:override) and xs:redefine are not supported; the tool says so when a schema uses them. DTDs are not validated.
    • The schema is not checked for ambiguous content models (the "Unique Particle Attribution" rule) or for every rule that makes a complex-type restriction valid, so some schemas that xmllint or Xerces refuse are accepted here. Documents are still checked against what the schema says.
    • Where libxml2 (xmllint) departs from the specification, this validator follows the specification: an empty xs:NMTOKENS or xs:IDREFS list is invalid, IDREFs must point to an existing ID, fixed values compare as values (05 equals 5 for an xs:int), "1.5e" is not a number, and a date without a time zone only compares with a bound that has one when they are more than 14 hours apart. So results can differ in those cases.
    • Elements may be nested up to 1,000 levels deep. The list shows the first 500 problems; validation always covers the whole document.
    • xs:ENTITY values are accepted only for unparsed entities declared in the document's internal DTD subset.

    Privacy

    Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.

    Frequently asked questions

    Is my XML or my schema uploaded?

    No. Both are parsed and validated in your browser (in a background worker, so large files do not freeze the page), and the page works offline once loaded — safe for invoices, personal data and internal schemas. External files and DTDs are never fetched.

    What does "No matching global declaration available for the validation root" mean?

    The schema has no top-level <xs:element> with the root element's name in the root element's namespace. Most often the namespace is the problem: the schema has a targetNamespace and the document does not declare it (add xmlns="…" to the root element), or the other way round. The message says which declaration exists and what to change.

    Why is a child element "not expected" when its name is right?

    Its namespace differs from the declaration's. With elementFormDefault="qualified" the children are in the target namespace too, so a document that declares the namespace only with a prefix on the root (<lib:library xmlns:lib="urn:lib"><book/>) puts <book> in no namespace. The message explains which namespace is expected. If the name and namespace are right, the element is in the wrong position or repeats too often.

    Which version of XML Schema is supported?

    XML Schema 1.0 (Second Edition), which is what most published schemas, libxml2 (xmllint) and most libraries implement. Schemas that use XML Schema 1.1 features are reported instead of being validated incorrectly.

    How is this different from xmllint or a Java validator?

    It is an independent implementation written for this page, not a port of libxml2 or Xerces. It reports the same kinds of errors with similar wording ("This element is not expected. Expected is …") plus explanations, and after a misplaced element it still checks the remaining children against their declarations. The limitations above list where results can differ.

    Quick answers and tool search

    Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.