JSON Schema Generator
Generate a JSON Schema from sample JSON data
100% free. Runs entirely in your browser - your files and data never leave your device and nothing is uploaded to any server.
About this tool
Writing a JSON Schema by hand is tedious and error-prone, so generating a first draft from real data is usually the faster route. The generator reads your sample and infers the structure: which fields exist, what type each holds, how objects nest, what arrays contain. What it produces is an accurate description of that one example - and understanding that limitation is what makes the output useful rather than misleading. A single sample cannot tell the generator which fields are genuinely optional, what range a number is allowed to take, which string is really an enum of three values, or that a field is sometimes null. Everything absent from your example is invisible to it. So treat the result as a scaffold: correct in its shape, deliberately loose in its constraints, and needing a pass by hand to tighten the rules that actually matter. Generation runs in your browser, so API payloads are never transmitted.
How to use this tool
- Paste a representative JSON sampleUse a realistic payload rather than a minimal one - fields absent from the sample cannot appear in the schema.
- Generate the schemaTypes, nesting and structure are inferred from what is present.
- Mark what is genuinely optionalThe generator assumes fields it sees are required. Only you know which ones are not.
- Tighten the constraints that matterAdd ranges, patterns, enums and additionalProperties: false where correctness depends on them.
From generated schema to a schema you can trust
The generator describes the sample you give it, so treat the output as a first draft. Check which fields should really be required, loosen types where real data varies - a field that can be a number or null, for example - and add formats such as email, date-time or uri.
Generate from several varied samples rather than one, then test the schema against real data in the JSON Schema Validator before relying on it.
Key features
- Produces a correct structural draft in seconds instead of an hour of hand-writing.
- Infers nesting and array item types, which are the tedious parts to write manually.
- Runs in your browser - real API payloads containing customer data are never uploaded.
- Gives a starting point you can then tighten, rather than a blank file.
- No account and no size limit.
Common uses
- Documenting the shape of an existing API response.
- Bootstrapping validation for a payload you already receive.
- Producing a contract to share with another team.
- Learning JSON Schema syntax by seeing it derived from familiar data.
- Checking that two similar payloads really do share a structure.
Tips for better results
- Feed it your most complete example. Optional fields missing from the sample simply will not appear in the schema.
- Review which fields it marked required - it assumes everything present is mandatory, which is rarely true.
- Add additionalProperties: false if you want misspelled keys caught, since the default permits any extra field.
- Replace inferred string types with enum where a field only ever holds a few known values.
- Once tightened, test it with the JSON Schema Validator against both good and bad payloads.
Mistakes to avoid
- Using the generated schema unchanged, which validates almost nothing beyond basic shape.
- Generating from a minimal sample and then wondering why real payloads fail validation.
- Leaving every field marked required when several are optional in practice.
- Assuming a field with a numeric value should accept any number, when the real range is narrow.
- Treating the output as documentation without tightening it - a permissive schema gives false confidence.
Frequently asked questions
It infers structure and types directly from your sample data, so it accurately reflects that example - but it can't know about optional fields, valid ranges, or variations that simply aren't present in the one sample you provided. Review and adjust the generated schema for edge cases.
Yes - paste it into the JSON Schema Validator tool (or any standard JSON Schema-compatible validator) to check other JSON data against it.
Yes, because it only sees one sample and cannot know which fields are optional in practice. Reviewing that list is the single most important edit to make before using the schema for real validation.
Usually because the sample was too narrow. Fields that are sometimes absent were marked required, or a field that is occasionally null was typed as a plain string. Generate from your most complete example, then loosen what genuinely varies.
If you want unexpected or misspelled fields to be caught, yes. By default a schema permits any property it does not mention, so a typo in a key name passes validation while the correctly named field is silently missing.
No. Generation runs in your browser, which matters because the samples people paste are usually real API responses containing customer records.
Feed it a sample that includes every optional field and a realistic mix of values - at least one item with each variation. The generator can only describe what it sees, so an array of one object gives a narrower schema than a varied one.
Add descriptions, mark which fields are truly required, add limits such as minLength, minimum or enum where the data has rules, and loosen types where a field can be null. Then validate a few real records against it.
Yes, with minor adjustments: OpenAPI 3.1 uses JSON Schema directly, while 3.0 uses a close dialect that, for example, writes nullable: true instead of a null type. Paste the generated object under components/schemas.