JSON Schema Generator

Turn one real payload into a schema you can actually enforce.

JSON sample
JSON Schema

About this tool

Generate a JSON Schema from a sample payload. The schema describes what your sample actually contains — every property typed, arrays described by their items, nesting followed all the way down.

Choose the draft (2020-12 by default; draft-07 for older toolchains), whether every property is required, and whether objects reject properties the sample did not show. Those three choices are where schema generators usually impose opinions silently; here they are controls on the toolbar.

Integers beyond 2⁵³−1 are typed integer or string, because a validator that reads them as numbers would round them — the note under the output says when this fired.

How to use it

  1. Paste a real payload — one that shows every field, including optional ones if you can.
  2. Pick the draft and the strictness: all-required, and whether to reject undeclared properties.
  3. Copy the schema into your project, or take it straight to the schema validator to see it accept the sample it came from.

Worked example

The sample above becomes an object schema with user, roles and active properties — user an object with string members, roles an array of strings, active a boolean — nested to exactly the depth the sample shows.

One sample, one enforceable schema

Frequently asked questions

Which draft should I choose?
2020-12 is the current standard and what most modern validators expect. draft-07 remains common in older toolchains and documentation; it reads the same core keywords, so the generated schema differs only in its $schema line here.
What does "all properties required" do?
By default the schema requires nothing — the sample cannot tell which fields are optional. Turning this on marks every property required, which is right for strict configs and wrong for API responses with optional fields; edit the required list afterward where you know better than the sample.
Should I enable additionalProperties: false?
Only for closed shapes: configuration files, event envelopes, anything with a fixed contract. API payloads usually keep the default permissive so clients can add fields without breaking validation.
How are array items described?
Identical members produce one clean items schema. Differing members union their shapes with anyOf — the honest description of heterogeneous data, rather than the shape of the first item.
Does it generate formats like date-time or email?
No — a sample shows the value, not the rule. A string that happens to hold a date is indistinguishable from any other string, so inventing a format would be a guess. Add format keywords by hand where your contract has them.