xmltoolskit.org
XML utilities, in the browser
Say hi →

XSD to sample XML

updated 20 August 2026 · XSD 1.0 subset · sample instance

Paste an XSD and get a skeleton XML document that matches it — element structure, attributes, and a plausible placeholder value for every built-in type. It is the fastest way to see what a schema actually expects.

xsd → xml
Drop a .xsd file here, or
ready

XSD to sample XML

The schema is read as a document: global xs:element declarations are the candidate roots, xs:complexType definitions supply children and attributes, xs:sequence and xs:all are expanded in order, xs:choice takes its first branch, and xs:group references are followed. Values come from the type: xs:int gives 42, xs:date gives a date, an enumeration gives its first allowed value.

How to use it

  1. Paste your XSD, or drop the .xsd file on the left pane.
  2. Leave Root element blank to use the first global element, or name one if the schema declares several.
  3. Set Repeat unbounded to 2 or 3 so repeating elements are visibly repeating.
  4. Copy the sample, adjust the values, and use it as a test fixture or a request body.

How values are chosen

Each element's type decides its placeholder: numeric types give 42 or 3.14, xs:boolean gives true, xs:date and xs:dateTime give well-formed dates, xs:anyURI gives a URL, xs:base64Binary gives a short encoded string, and a plain xs:string gives elementname-value so you can see which element produced it.

Where a simple type restricts a base type with an enumeration, the first enumerated value is used instead of a generic placeholder — which is usually exactly what a consumer needs to accept the document. Attribute fixed and default values are honoured the same way.

Choices, optionality, and recursion

An xs:choice has no single right answer, so the first branch is emitted. Optional particles (minOccurs="0", attributes with use="optional") are included by default — a fuller sample is more useful when you are exploring a schema — and can be excluded with one tick when you want the minimal valid document instead. Turning on comments marks each optional element in the output so you can see what is safe to delete.

Recursive schemas — an element that contains itself, directly or through a chain — are cut off with a comment after 25 levels rather than looping forever.

What is not supported

This is a pragmatic subset of XSD 1.0, not a full processor. Not handled: xs:import and xs:include of other schema files (paste one self-contained schema), substitution groups, abstract types with xsi:type selection, xs:any wildcards, identity constraints, and xs:assert from XSD 1.1. Facets other than enumeration — patterns, lengths, ranges — are not used to shape the placeholder, so a generated value can violate a pattern.

Because of that, treat the output as a skeleton to edit rather than a guaranteed-valid instance. Run it back through the schema validator to see where it needs real values.

FAQ

Will the generated document validate against the schema?

Often, but not always — pattern, length and range facets are not applied to placeholder values, and a choice branch may not be the one your consumer expects. Check with the schema validator and edit the values.

My schema imports another file. What happens?

The import is ignored, so elements whose types live in the other file come out as plain placeholders. Paste a single self-contained schema, or inline the imported definitions first.

How do I pick which root element to generate?

Type its name into Root element. If the name does not exist, the error message lists the global elements the schema does declare.

Why are optional elements included by default?

Because the usual reason to generate a sample is to see everything a schema allows. Untick include optional for the minimal document — useful when writing a test for required fields only.

Is my schema uploaded?

No. The XSD is parsed and the sample generated entirely in your browser.

Related tools

Privacy

100% client-side. The schema is parsed locally and the sample built in the page. See the privacy policy.