Skip to main content

XSD Generator

Generate an XML Schema (XSD) from a sample XML document — infers element nesting, repeat counts, optional vs required attributes, and data types (integer, decimal, boolean, date). Runs entirely in your browser.

Input

Output

Generated XSD
 
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/xsd-generator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "xmlInput": "<library><book id=\"1\" available=\"true\"><title>Du…",
    "inferTypes": "true"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `xsd-generator` tool (XSD Generator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/xsd-generator/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="XSD Generator — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

Paste a sample XML document and get an XML Schema (XSD) that describes it. Instead of writing a schema by hand, let the generator read your example and work out the structure, repeat counts, attributes, and data types for you.

What it infers

  • Nesting. Every element becomes an xs:element, with child elements nested inside their parent (the "Russian Doll" style).
  • Repeats and optional children. A child that appears more than once in any parent gets maxOccurs="unbounded"; one missing from some parents gets minOccurs="0".
  • Attributes. An attribute present on every instance is required; otherwise it is optional.
  • Data types. With type inference on, values are typed as xs:boolean, xs:integer, xs:decimal, xs:date, xs:dateTime, or xs:string. If samples disagree (say 7 and 9.99), the type widens to xs:decimal, or falls back to xs:string.
  • Ordering. If children always appear in a consistent order the schema uses xs:sequence; if the order varies between samples it uses a repeating xs:choice so your example still validates.

How to use it

  1. Paste your XML, or click Try an example.
  2. Toggle Infer data types off if you want every value as xs:string.
  3. Copy or download the generated schema.xsd.

Limits worth knowing

A schema inferred from one example only knows what that example shows. A field that is always present in your sample will be marked required, even if it is optional in real data — feed it a representative document with several records, then review the result. Namespaces are not modeled: element and attribute names use their local names.

Check your XML is well-formed with the XML Validator, tidy it with the XML Formatter, or produce a JSON equivalent with the JSON Schema Generator.

Privacy

Everything runs in your browser. Your XML is never uploaded.

xmlxml-schemaschemainferxml-to-xsddeveloperxsd-from-xmlvalidate

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.