Advertisement728 × 90 — Leaderboard
Advertisement320 × 50 — Mobile banner

Generate JSON Schema Online

Infer a JSON Schema from any JSON sample — Draft 7, 2019-09, 2020-12
Session restored from your last visit
Also need:JSON FormatterJSON Schema ValidatorJSON to TypeScript
Advertisement — Fullscreen
Input
Output
Input
AdvertisementResponsive
Output
Copy as JSON
Copy Escaped
Copy as Base64
Copy as cURL
Ready0 chars0 lines
Advertisement728 × 90

About Generate JSON Schema Online

Paste any JSON and get a matching JSON Schema inferred automatically. The generator detects types (string, number, integer, boolean, null, array, object), handles nested objects and mixed-type arrays, and optionally marks all properties as required, adds examples arrays, and sets additionalProperties: false. Supports JSON Schema Draft 7, Draft 2019-09, and Draft 2020-12. All processing runs in your browser — nothing is sent to a server.

Frequently Asked Questions

What is a JSON Schema generator?
A JSON Schema generator analyses a JSON sample and produces a schema that describes its structure — the types of each field, which properties are required, and how arrays are typed. The generated schema can be used for validation, documentation, and code generation.
How accurate is a JSON Schema auto-generated from a sample document?
Accuracy depends on how representative your sample is. A single sample can only infer what it sees — null values become nullable, always-present fields become required. For production schemas, use the generated output as a starting point and manually add optional fields, enum constraints, string patterns, and min/max value rules.
Can I generate a JSON Schema from a TypeScript interface or class?
This tool generates schemas from JSON data samples, not TypeScript source. For TypeScript-to-schema generation, use the ts-json-schema-generator CLI or the TypeScript JSON Schema library, which read .ts files directly and output draft-compliant schemas, preserving optional (?) and nullable (| null) type annotations.
Which JSON Schema draft does the generated schema target by default?
The generator targets Draft 7 by default, which has the broadest support across validators, code generators, and documentation tools. Switch to Draft 2020-12 if you need keywords like prefixItems for typed array tuples or unevaluatedProperties for schema composition. The $schema declaration in the output identifies the draft used.
How do I handle optional fields and nullable values in a generated schema?
Optional fields (absent from some sample objects) are automatically excluded from the required array. Nullable fields (where null appears in the sample) get a type union: {"type":["string","null"]}. For fields that can be null but were not null in your sample, manually edit the generated schema to add null to the type.
Advertisement300 × 250
Advertisement300 × 250
Ad
AdvertisementSticky banner
Ad
AdvertisementSticky banner