XSD Generator

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

Paste a sample document and get an XSD schema that describes it.

How to use it

  1. Paste a sample XML document, or a JSON document. Press Example to try one.
  2. The XSD appears automatically.
  3. Read it through, adjust types and limits, then copy or download it.

What it works out

From JSON

JSON has no schema in XSD terms, so the tool first turns the JSON into XML the same way as JSON to XML, then describes that XML. When the JSON has one top-level field, that field becomes the outer element; otherwise Root name is used.

Check the result

The schema is guessed from one sample. A value that happens to be a whole number may need to be a decimal or text, and an element that appears once may be allowed to repeat. Review it against all the data it must accept. Validating documents against an XSD is not included.

Example

Made-up input, and what XSD Generator returns for it. Long text is shortened.

Sample XML or JSON
<orders xmlns="urn:example:orders">
  <order id="1001" status="open">
    <customer>Demo User</customer>
    <placed>2026-01-31</placed>
    <item sku="A1"><qty>2</qty><price>9.50</price></item>
    <item sku="B7"><qty>1</qty><price>3</price></item>
    <note>Leave at the door</note>
  </order>
  <order id="1002">
    <customer>Test User</customer>
    <placed>2026-02-01</placed>
    <item sku="C2"><qty>5</qty><price>1.25</price></item>
  </order>
</orders>
Result
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:example:orders" xmlns="urn:example:orders">
  <xs:element name="orders">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="order" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="customer" type="xs:string"/>
              <xs:element name="placed" type="xs:date"/>
              <xs:element name="item" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="qty" type="xs:integer"/>
                    <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:integer" use="required"/>
…

Questions

Does it make named types?

No. Types are written inside each element, which is easy to read and to change.

Can I get a sample back from a schema?

Yes, with XSD to sample XML.

Related tools

See all tools