Paste an XML Schema (XSD) and get a sample XML document that follows it: the right element order, required and optional elements, repeated items, attributes, enumeration values, pattern-matching strings and the target namespace. Pick the root element, decide how much optional content to include and copy or download the result.
Last updated:
The schema is parsed by your browser and never uploaded. Included or imported schema files are not fetched; paste a self-contained XSD.
Advertisement
Advertisement
How to use the XSD to XML Sample Generator
Paste your XSD into the left box, open an .xsd file, or load one of the examples.
Pick the root element. The generator preselects the top-level element that is not used inside others.
Choose the options: include optional elements and attributes or keep it minimal, how often repeating elements appear, and realistic values or type-name placeholders.
Press Generate XML (Live update also regenerates as you edit) and read any notes about unsupported parts.
Copy or download the sample, then replace the values with real data.
How XSD constructs become XML
Schema construct
In the generated sample
xs:sequence
Child elements in exactly the declared order.
xs:choice
One option (the first), with a comment listing the alternatives.
xs:all
Each child once, in declaration order (any order would be valid).
minOccurs="0"
Included or left out depending on the Optional items setting.
maxOccurs="unbounded"
Repeated 1, 2 or 3 times according to Repeat lists.
complexContent/extension
Base type content first, then the extension's elements and attributes.
simpleContent/extension
Text value of the base type plus the added attributes.
xs:enumeration
One of the allowed values; repeated elements cycle through them.
xs:pattern
A generated string that matches the regular expression.
fixed / default
The fixed value is always used; the default is used as the sample.
xs:list
Space-separated values of the item type.
xs:any
A comment marking where any element may appear.
Sample values for common built-in types
Type
Sample
Lexical rule
xs:date
2025-03-14
YYYY-MM-DD, optional time zone
xs:dateTime
2025-03-14T09:30:00Z
Date, T, time with seconds
xs:time
09:30:00
Seconds are required
xs:decimal
42.50
No exponent; fractionDigits limits decimals
xs:boolean
true
true, false, 1 or 0
xs:duration
P2DT3H
ISO 8601 duration
xs:ID
task-1
Unique NCName; cannot start with a digit
xs:anyURI
https://example.com/resource
Any URI reference
To go the other way and infer a schema from existing XML documents, use the XML to XSD Generator.
Frequently asked questions
How do I generate an XML file from an XSD?
Paste the schema, choose the root element and press Generate XML. The tool walks the schema from that element, writes child elements in the order the sequences define, adds required attributes and fills each value with something that fits its type and facets.
Is the generated XML valid against the schema?
For self-contained schemas it is designed to be: element order, occurrence counts, enumerations, numeric ranges, lengths and patterns are respected. Constructs such as identity constraints (xs:key, xs:unique), assertions and xs:any wildcards are not filled in, so validate the result if it matters.
Which element is used as the root?
Any global xs:element can be the root of a document. The tool preselects a global element with complex content that no other element references, which is usually the intended root, and you can switch to any other global element in the list.
What happens with xs:choice?
The first option is used, and with comments on, a comment lists every option. When the choice repeats, later repetitions rotate through the other options so you can see them all.
Does it support xs:import and xs:include?
Referenced files cannot be fetched from the browser, so types defined in them become placeholders and a note lists the missing files. Merge the schemas into one file or paste the main schema with the needed types copied in.
How are namespaces handled?
If the schema has a targetNamespace and elementFormDefault="qualified", the document uses it as the default namespace. With unqualified local elements, only global elements get a prefix. Qualified attributes always get the prefix, and xsi:schemaLocation can be added for validation.
What does Type names as placeholders do?
Instead of sample values, each element and attribute shows its type, for example decimal or MemberIdType. This is handy as a template that shows what goes where, though the result is not valid until you fill in real values.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.