XML to XSD Converter

Infer an XSD schema from sample XML, then validate your XML against it

Generate an XSD schema from sample XML online, then validate your XML documents against it. The XML to XSD converter infers elements, attributes, data types, and structure automatically, saving hours of manual schema writing. It is ideal for developers working with SOAP services, data integrations, and XML-based configuration files.

XML Input
XSD Schema

About XML to XSD Converter

This tool analyses a sample XML document and infers an XML Schema Definition (XSD) that describes its structure: element names, nesting, attributes, occurrence rules and simple data types. The generated schema is a starting point that you can edit directly in the right-hand panel and then use to validate XML documents. Parsing runs on the server with DTD processing disabled, and your data is not stored.

Key Features

  • Schema inference — generates elements, complex types, attributes and types such as xs:int, xs:decimal, xs:date and xs:boolean.
  • Occurrence and type options — choose restricted rules for a tight schema, or relaxed rules for optional elements and general types.
  • Validate button — checks the XML is well-formed and conforms to the XSD in the right panel, listing each problem with its line and position. Click a problem to jump to it.
  • Editable output — paste any XSD into the schema panel to validate against your own schema.
  • Copy and download — save the schema as schema.xsd.

How to Use

  1. Paste or upload representative XML and click Generate XSD.
  2. Review and adjust the schema if needed.
  3. Click Validate to check the XML against the schema. With an empty schema panel, only well-formedness is checked.

Notes

  • A schema inferred from one sample only knows what that sample shows. Use several representative documents merged into one, or the relaxed options, for more general schemas.
  • Schemas that import or include other files are not resolved, because external resources are never loaded.
  • Documents that contain a DOCTYPE are rejected, because DTD processing is disabled for safety.

Related Developer Tools

Format your document with the XML Formatter, create paths with the XPath Generator, or build classes with the XML to C# converter.

What Is an XSD?

An XML Schema Definition (XSD) is a W3C standard that describes what a valid XML document looks like: which elements and attributes may appear, in what order, how many times, and what kind of value each one holds. An XML file is well-formed when its syntax is correct, and valid when it also follows a schema. Validation lets a sender and receiver agree on a data contract, and it catches missing fields, wrong types and unexpected elements before they cause errors further down the line.

How the Schema Is Inferred

The generator reads your sample once and records every element, attribute and value it finds. Elements that contain other elements become complex types. Repeated elements get a maximum occurrence of unbounded. Text values are checked against the built-in XSD types, so 44.95 becomes xs:decimal, 2000-10-01 becomes xs:date, and plain words become xs:string. With Restricted occurrence an element seen in the sample is required, while Relaxed makes it optional. With Relaxed types, values that do not fit a specific type fall back to a more general one instead of causing a narrow type to be chosen.

Typical Workflow

  1. Generate a first draft from a realistic sample document.
  2. Tighten it by hand: add enumerations, patterns, length limits or minOccurs and maxOccurs values that the sample cannot reveal.
  3. Validate several real documents against the edited schema and read the reported line and position for each problem.
  4. Download the schema and use it in your build, API gateway or import process.

Use Cases

  • Creating a contract for an XML API, feed or file exchange between systems.
  • Validating configuration files, invoices, product catalogues and data imports before processing them.
  • Generating strongly typed classes in other tools, many of which start from an XSD.
  • Documenting an undocumented XML format by letting the tool describe its structure.
  • Checking that a hand-written XSD accepts valid examples and rejects invalid ones.

Understanding Validation Messages

A message such as The element 'catalog' has invalid child element 'item' means the XML contains an element the schema does not allow at that position. The 'price' element is invalid usually means the text does not match the declared type, for example letters in a decimal field. A message about a missing element means the schema requires something the XML does not contain. Warnings are shown separately from errors and do not make the document invalid. If the XSD itself has a mistake, the tool reports that first, so you can fix the schema before checking any XML against it.

Frequently Asked Questions

Why does validation fail for XML I just generated the schema from?

It should not. If you edited the XML or the schema afterwards, the issue list shows what no longer matches.

Can I use the schema in production?

Treat it as a draft. Review types, optional elements and enumerations before relying on it.