XML tools

XML to XSD generatorfrom real samples

Compare one XML document with a second sample to see which fields become optional.

XML to XSD generator

XML samples

XSD draft

Samples stay in this browser. Local files are read here and are not uploaded.

Inference options

Up to 20 samples, 1,000,000 characters each, 2,000,000 in total and depth 100. Blank samples are ignored.

Result is out of date; export is disabled.

An XML to XSD generator helps when an integration sends example payloads but no schema. Each document is evidence of what occurred, not proof of everything the sender permits.

Here you can generate XSD from XML samples in one browser tab. The draft is compiled and checked against every sample before export, so an order conflict or unsupported namespace fails visibly.

Why use this XML to XSD generator?

Discover omissions across documents

Two same-root samples can show a field absent from one instance. The XML to XSD generator marks that observed omission with minOccurs=0, while repeated siblings become maxOccurs=unbounded. It does not guess unseen alternatives.

Two XML sample trees join into a schema tree where a missing field has an optional marker.

Keep each parent shape separate

A customer name and a product name can have different structures. Local XSD declarations preserve their distinct parent paths; the completed schema is then checked against both inputs instead of trusting the first result.

Same-named child nodes beneath different parent branches lead to separate schema declarations.

What the samples can and cannot tell you

01

Add a second whole document

Each sample needs one complete XML root. Blank extra editors are ignored; a second document can expose a missing child or attribute that one document cannot reveal.

02

Choose how to read values

Smart infers booleans, numbers and ISO dates conservatively. Switch to String when codes such as 001 or mixed value formats must remain text. Automatic generation waits 400 ms; turn it off for several edits and press Ctrl/Cmd+Enter.

03

Inspect the draft's claims

A successful result compiles as XSD 1.0 and accepts every supplied sample. Before using it with new data, review minOccurs, maxOccurs, type guesses and xs:sequence; samples alone cannot define the business contract.

From observed XML to a checked draft

Merge multiple examples

The XML schema generator combines matching root documents. A child missing under one observed parent is optional; sibling names repeated under one parent get an unbounded maximum. Attributes follow the same observed-presence rule.

Conservative value inference

The infer XSD from XML workflow detects clear boolean, integer, decimal and ISO date values. Empty strings, conflicts and codes with leading zeroes stay xs:string; no example proves a range or enumeration.

Compile and verify before export

The XSD 1.0 draft uses local declarations to avoid merging identical names under unrelated parents. A browser worker compiles it and checks every input; only then can you copy or download the complete schema.

Where an inferred schema stops

Observed presence is not a business rule
A field present in every sample is required in this draft, even if production allows it to be absent. Only an observed omission makes minOccurs=0 or an attribute optional. Review those decisions manually.
No invented constraints
The generator does not infer enumerations, patterns, ranges, keys, defaults or cross-field conditions. A numeric-looking identifier with leading zeroes stays a string; a different format may also widen a type to xs:string.
One root and one namespace
All nonempty samples need the same root expanded name. Elements from a second namespace, namespaced data attributes, mixed text with child elements and conflicting sibling order are refused rather than silently flattened.
Local XML 1.0 only
Pasted text or local UTF-8 files are parsed here. DOCTYPE, declared entities, XML 1.1, URL fetching and external schemas are not supported. The output is XSD 1.0 with a single schema.xsd file.
Bounded draft, separate validation task
At most 20 samples, 2,000,000 total characters and depth 100 are accepted. The built-in check covers only the supplied samples; use the separate XSD validator for another XML document. A passing sample check does not certify a receiving system.

XML to XSD generator questions

Can I generate a schema from more than one XML sample?

Yes. Add up to 20 complete documents with the same root and namespace. The XML to XSD generator merges observed children and attributes, then verifies that its one output schema accepts every nonempty sample.

How do I make an element optional in the generated XSD?

Include at least one occurrence of its parent without that child. The inferred declaration then gets minOccurs=0. A field present in every sample cannot be proved required; edit the draft if your real contract allows omission.

Why was a postcode inferred as an integer?

Digits without leading zeroes look numeric to Smart mode. Switch to String before generating if identifiers should always remain text. Values such as 001 already remain xs:string because dropping the zero would change their meaning.

Can a generated XSD validate a different XML document?

It can be a starting schema, but the internal check proves only that the source samples pass. A new document may expose missing alternatives, a different order or a wider value type. Test it with the separate XSD validator and refine the draft.

Will my XML be uploaded to create a schema?

No sample is submitted for generation. The browser reads local files and runs parsing, inference and XSD checking in a worker. Copy and download happen only when you request them; reloading the page discards the current inputs.

Does a guess need a closer look?

Build an XML to XSD generator draft

Use the XML to XSD generator with a second representative payload, inspect the optional and repeated declarations, then validate a new document before adopting the schema.