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
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_HEREPaste 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 call | From 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 getsminOccurs="0". - Attributes. An attribute present on every instance is
required; otherwise it isoptional. - Data types. With type inference on, values are typed as
xs:boolean,xs:integer,xs:decimal,xs:date,xs:dateTime, orxs:string. If samples disagree (say7and9.99), the type widens toxs:decimal, or falls back toxs:string. - Ordering. If children always appear in a consistent order the schema uses
xs:sequence; if the order varies between samples it uses a repeatingxs:choiceso your example still validates.
How to use it
- Paste your XML, or click Try an example.
- Toggle Infer data types off if you want every value as
xs:string. - 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.
Related tools
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.