Home › Developer Tools › XSD Validator

XSD Validator

Paste an XML document and its XSD schema to check that the XML follows the schema: element order and counts, required attributes, data types, enumerations, patterns, lengths and ranges. Each error shows the line in your XML and what the schema expected.

Last updated:

    …
    Waiting for inputPaste an XML document and its XSD schema.

      Validation runs in your browser with a built-in XML Schema 1.0 engine. Nothing is uploaded. Tip: Ctrl + Enter validates.

      Advertisement
      Advertisement

      How to use the XSD Validator

      1. Paste the XML into the left editor, or open or drop a file. A sample purchase order with errors loads first.
      2. Paste the XSD into the right editor. If it uses xs:include or xs:import, add those files with + Imported .xsd.
      3. Read the result. Green means the XML conforms to the schema; otherwise each error explains what was wrong and what was expected.
      4. Click an error to jump to its line. Lines with errors are highlighted red in the line numbers.
      5. Fix and re-check. Validation reruns as you type, or press Validate XML (Ctrl + Enter).

      How XSD validation works

      A validator walks the XML tree from the root down. The root must match a global element declaration. Each element's type then decides what it may contain:

      • Simple types (like xs:date or a restricted xs:string) allow text only. The text is normalised for whitespace and checked against the type and its facets.
      • Complex types allow attributes and, depending on the content model, child elements in a sequence (fixed order), choice (one of) or all (any order, each at most once), repeated as minOccurs/maxOccurs allow.
      • Identity constraints (xs:unique, xs:key, xs:keyref) are checked last, across the elements they select.

      Common XSD validation errors and fixes

      ErrorUsual causeFix
      No matching global element declarationRoot name or namespace differs from the schemaAdd the schema's targetNamespace as xmlns in the XML
      Element is not expected hereWrong order in a sequence, a missing element before it, or too many repeatsFollow the order shown under Expected
      Element is incompleteA required child (minOccurs ≥ 1) is missing at the endAdd the listed element
      Attribute is not allowedTypo, wrong case, or an attribute the type does not declareNames are case-sensitive; check the spelling
      Value is not one of the allowed valuesValue outside an xs:enumerationUse one of the listed values exactly
      Value does not match the patternxs:pattern regex fails; patterns match the whole valueCheck the format, e.g. ORD-\d{5} needs exactly five digits
      Not a valid datexs:date needs YYYY-MM-DD, and the day must existWrite 2026-03-14, not 14/03/2026
      Has 3 decimal placesfractionDigits or totalDigits exceededRound the number

      Tips

      • elementFormDefault matters. With elementFormDefault="qualified", child elements must be in the target namespace too, which a default xmlns="…" on the root takes care of.
      • xsi:schemaLocation is only a hint. Validators, including this one, use the schema you supply rather than downloading the location from the XML.
      • No schema yet? Draft one from a sample document with the XML to XSD Generator, and check plain syntax with the XML Validator.

      Frequently asked questions

      What is the difference between well-formed and valid XML?

      Well-formed XML follows the basic syntax rules: one root element, properly nested and closed tags and quoted attributes. Valid XML is well-formed and also follows a schema, which defines which elements and attributes may appear, in what order, how often and with which data types. This tool checks both: syntax first, then the XSD rules.

      How do I validate XML against an XSD?

      Paste the XML on the left and the schema on the right. The root element of the XML must match a global xs:element declared in the schema, including its namespace. Every child element, attribute and text value is then checked against the declared types, and each violation is listed with its line number.

      Why do I get 'No matching global element declaration'?

      The root element name or namespace does not match a top-level xs:element in the schema. If the schema has a targetNamespace, the XML must declare the same namespace, for example xmlns="urn:example:orders". Local elements declared inside a type cannot be used as the root.

      What does 'Element is not expected here' mean?

      The element is not allowed at that point of the content model: it may be in the wrong order inside an xs:sequence, appear more often than maxOccurs allows, or not be declared at all. The message lists the elements the schema expected at that position, which usually points straight to the fix, such as a missing required element before it.

      Does it support xs:include and xs:import?

      Yes, but the browser cannot fetch files from your disk or network automatically. Add the referenced schema files with + Imported .xsd. Until they are added, the tool warns you and skips the types and elements that come from the missing files.

      Which XSD version is supported?

      XML Schema 1.0, which is what most real-world schemas use. XSD 1.1 features such as xs:assert, xs:alternative and xs:override are not evaluated; when a schema uses them, a warning is shown instead. Regular expression patterns are translated to JavaScript, so a few rare XSD regex features such as Unicode block names are approximated.

      Is my XML uploaded anywhere?

      No. Both files are parsed by your browser's XML parser and validated by JavaScript on this page, so private data and internal schemas never leave your computer.

      Are all the tools on FreeToolCabin tested for quality and accuracy?

      Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

      Related tools

      XML ValidatorCheck if XML is well-formed, see the exact line and column of each error and pretty-print it.XML to XSD GeneratorGenerate an XML Schema (XSD) from sample XML: types, occurrences, attributes and namespaces.XML FormatterBeautify, validate and minify XML with a collapsible tree view.JSON Schema ValidatorValidate JSON against a JSON Schema (draft-07, 2019-09, 2020-12) with clickable error paths.JSON FormatterBeautify, minify and validate JSON, with a collapsible tree view.SQL Formatter & BeautifierFormat, beautify or minify SQL queries for MySQL, PostgreSQL and more.JavaScript BeautifierFormat and beautify messy or minified JavaScript, or minify it.HTML FormatterBeautify and indent HTML code with a live preview.CSS FormatterBeautify CSS with indent controls and optional property sorting.ZIP File CreatorCompress files and folders into a ZIP.YAML Validator & FormatterValidate, format and minify YAML, and convert YAML to JSON or back.HTML MinifierMinify HTML: strip comments and whitespace safely and see how many bytes you save.CSS MinifierMinify CSS with csso or a built-in engine and see the size saved instantly.JavaScript MinifierMinify JavaScript with Terser: compress, mangle and see how many bytes you save.JSON MinifierMinify and validate JSON, sort keys and see exactly how many bytes you save.Code Diff CheckerCompare two code files side by side or unified, with syntax colors and changes highlighted.IPv6 Expander & CompressorExpand IPv6 addresses to full form or compress them per RFC 5952, one or many at once.GraphQL FormatterPretty-print and indent GraphQL queries, mutations and schemas, or minify them, instantly.CSS ValidatorValidate CSS: syntax errors, unknown properties and invalid values by line, plus auto-fix.Gzip Compress / DecompressGzip or deflate text and files, get Base64 output, and decompress Base64 or .gz files.IBAN ValidatorCheck an IBAN's mod-97 checksum, country and length, and see its bank code and account parts.JavaScript Syntax CheckerCheck JavaScript for syntax errors with line and column, for any ES version, script or module.Markdown FormatterBeautify Markdown with Prettier: list markers, prose wrap, aligned tables and live preview.PHP FormatterBeautify PHP code with Prettier PHP: PSR-12 style, indent and brace options, syntax errors.TypeScript FormatterFormat TypeScript and TSX code with Prettier: width, tabs, semicolons and quotes options.XML MinifierMinify and validate XML: strip whitespace and comments, keep CDATA, see the size savings.C# FormatterBeautify C# code online: Allman or K&R braces, indent size and line width, clang-format option.HTML ValidatorCheck HTML for errors and warnings with line numbers, locally or with the W3C Nu checker.Java FormatterBeautify Java code online: indent size, brace style and line width, with clang-format option.JavaScript ObfuscatorObfuscate JavaScript with string encoding, renaming and control-flow flattening presets.Phone Number FormatterFormat and validate lists of phone numbers to E.164, international or national style.Python FormatterFormat Python code in Black/Ruff style: line length, quote style, indent, copy or download.Responsive Design CheckerPreview any website at phone, tablet, laptop and desktop sizes side by side, with rotate and zoom.Browser Compatibility CheckerSearch CSS, JavaScript and HTML features and see which browser versions support them.Core Web Vitals CheckerCheck real-user LCP, INP and CLS for any URL or site and see if it passes Core Web Vitals.Heading Structure CheckerPaste HTML to see its H1-H6 outline and catch missing H1s, multiple H1s and skipped levels.Website Hosting CheckerFind out who hosts a website: hosting provider, IP addresses, ASN, network owner and location.Routing Number ValidatorCheck a US ABA routing number's checksum and format and see its Federal Reserve district.Strftime Format BuilderBuild Python and C strftime format strings by clicking tokens, with a live preview and reference.Spam Word CheckerScan an email subject and body for spam trigger words, excess caps, exclamation marks and risky links.Check Digit CalculatorCalculate or validate check digits for UPC, EAN, GTIN, SSCC, ISBN, ISSN and mod 11 codes.Luhn Algorithm CheckerValidate numbers with the Luhn mod 10 check or calculate the missing check digit, step by step.
      See all 41 Code Formatters & Validators →