XSD to Sample XML and JSON

Free. No sign-up. Your input is processed in your browser.

Paste an XSD schema and get an example document that follows it.

How to use it

  1. Paste your XSD schema, or press Example.
  2. Choose Make: XML or JSON. To start from another top-level element, type its name under Root element.
  3. Untick Include optional parts to leave out optional elements and attributes, then copy the sample.

What goes into the sample

Limits

Each element appears once, even when more are allowed. Values may not match a xs:pattern. Types that come from xs:import or xs:include are not loaded, because the editor makes no requests; they appear as text, and the tool says so. Elements that contain themselves are stopped after one level. The JSON sample uses the layout of JSON to XML, where attributes start with @.

Example

Made-up input, and what XSD to Sample XML and JSON returns for it. Long text is shortened.

XSD schema
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:example:shop" xmlns="urn:example:shop" elementFormDefault="qualified">
  <xs:element name="order" type="Order"/>
  <xs:complexType name="Order">
    <xs:sequence>
      <xs:element name="customer" type="xs:string"/>
      <xs:element name="placed" type="xs:date"/>
      <xs:element name="status" type="Status"/>
      <xs:element name="item" maxOccurs="unbounded">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="qty" type="xs:positiveInteger"/>
            <xs:element name="price" type="xs:decimal"/>
          </xs:sequence>
          <xs:attribute name="sku" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="note" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:int" use="required"/>
  </xs:complexType>
  <xs:simpleType name="Status">
    <xs:restriction base="xs:string">
…
Result
<?xml version="1.0" encoding="UTF-8"?>
<ns:order xmlns:ns="urn:example:shop" id="1">
  <ns:customer>text</ns:customer>
  <ns:placed>2026-01-31</ns:placed>
  <ns:status>open</ns:status>
  <ns:item sku="text">
    <ns:qty>1</ns:qty>
    <ns:price>1.5</ns:price>
  </ns:item>
  <ns:note>text</ns:note>
</ns:order>

Questions

Is the sample guaranteed to be valid?

No. It follows the schema closely, but patterns and some limits are not applied. Check it with a validator before you rely on it.

Can it make a schema from XML?

Yes, with the XSD generator.

Related tools

See all tools