JSON to XSD — Generate XML Schema from JSON
Generate XML Schema (XSD) from JSON data. ComplexType, sequence, restriction — in your browser, no upload.
JSON to XSD
Generate XML Schema (XSD) from JSON data. Generates XSD schema elements with inferred types (xs:string, xs:integer, xs:boolean, etc.). Works entirely in your browser.
XML Schema (XSD) is the formal contract language of XML-based systems. An XSD file defines what elements a valid XML document may contain, what order they must appear in, what types their values must be, and how many times they can repeat. Writing an XSD by hand from a sample XML or JSON document is the first step in integrating with any system that requires schema validation: SOAP web services, government data exchanges, financial transaction formats, and regulatory submissions. The JSON-to-XSD generator walks a JSON structure and emits the XSD that would validate the XML produced by a JSON-to-XML conversion of the same data.
The non-obvious architectural choice in XSD generation is the schema composition style. Russian Doll (one global element, all other types nested inside it) is the simplest and most common — it produces a single, self-contained XSD file that validates the exact structure of the sample JSON. Salami Slice (every element global, referencable by ref) and Venetian Blind (types global, elements local) are more reusable but more complex to read and maintain. The Russian Doll is the right default for one-off schema generation from a sample document. The other styles are the right choice when the generated types will be reused across multiple schemas or when the schema is part of a larger WSDL or XSD ecosystem.
How to use
Paste your JSON
Drop a JSON object into the input. The generator walks the structure and emits an XML Schema document with complexType definitions for each nested object shape.
Choose schema style
Picker between Russian Doll (nested types, most common), Salami Slice (global types with refs), and Venetian Blind (global types, local elements). Russian Doll is the default.
Copy or download the XSD
Copy the XSD to your clipboard or download as an .xsd file. The output is valid XML Schema 1.0 and validates with xmllint, Xerces, or any schema-aware XML parser.
Frequently asked
Which schema style should I choose?
Russian Doll has one global element (the root) and all other types are nested anonymous complexTypes inside it — the simplest, the most common, and the hardest to reuse. Salami Slice makes every element global and types reusable. Venetian Blind makes types global and elements local — the compromise. Start with Russian Doll.
How are JSON types mapped to XSD types?
JSON strings become `xs:string` with optional minLength/maxLength restrictions. Numbers become `xs:integer` or `xs:decimal` based on whether the sample contains a decimal point. Booleans become `xs:boolean`. Arrays become `xs:complexType` with a `sequence` of the element type.
Does it support XML namespaces?
Yes — toggle 'targetNamespace' to emit an XSD with a configurable namespace URI and the `xmlns:tns` prefix. The generated XML instance must use the same namespace to validate correctly.
How are optional elements handled?
Elements that are absent in some array members get `minOccurs="0"` in the schema, making them optional. Elements present in every array member get `minOccurs="1"` (required). Toggle 'all optional' to make every element optional.
Can it generate enumeration restrictions?
Toggle 'enumerations' to detect string fields with a fixed set of repeated values and emit `xs:restriction` with `xs:enumeration` values. A status field with 'active', 'pending', 'closed' across the sample becomes a restricted string.
Limitations
- No XSD 1.1 featuresThe output is XML Schema 1.0. XSD 1.1's assertions, conditional type assignment, and open content are not supported. For XSD 1.1 features, post-process by hand.
- No key/keyref constraintsThe schema does not infer primary key or foreign key relationships from JSON data. Add `xs:key` and `xs:keyref` constraints by hand if your schema requires referential integrity.
- Sample-dependent type widthsmaxLength and minLength restrictions are inferred from the longest and shortest observed values. If your API may return longer strings, adjust the maxLength by hand.
Platform notes
- macOS
- The generated XSD validates with xmllint (included with macOS) and any schema-aware XML editor. Use the browser tool for one-off schema generation during API documentation.
- Windows
- The XSD validates with Visual Studio's XML Schema Explorer and XMLSpy. Use it for one-off generation where a full IDE is not available.
- Linux
- For command-line work, `xjc` (JAXB) and `xsdata` can generate XML Schema. The browser tool is the right pick for one-off generation where a Java or Python toolchain is not available.
- Web
- Runs entirely client-side. The generation is instant.