Writing a JSON Schema from real data
A JSON Schema is a JSON document that describes other JSON documents. It says which keys an object has, which ones are required, and what type each value is. Validators such as Ajv check data against it, API tools use it to describe requests and responses, and editors use it to suggest keys as you type. Writing a schema by hand for a large payload is slow and easy to get wrong. Starting from a real sample and correcting the result is much faster.
This generator reads your sample and describes what it sees. Objects become type object with a properties list. Lists become type array with one items rule. Text, booleans and null get their own types. Numbers are split into integer and number using the digits you wrote, so 42 is an integer and 42.5 is a number. If one sample has 1 and another has 1.5 at the same place, the schema says number, because that covers both. The output declares draft 2020-12, the current version of the standard.
The useful part is how arrays are handled. Real data is a list of records, and records differ. The generator merges every item into one description. A key found in every record is listed as required. A key found in only some records is optional. A value that is sometimes text and sometimes null gets the type ["string", "null"]. So the more records you paste, the closer the schema gets to the truth. One record tells the tool almost nothing about which keys are optional.
String formats are detected when you leave the switch on: date-time, date, email, uri and uuid. A format is kept only when every sample of that string matches, so one free-text value turns it off. Formats are hints in draft 2020-12, and many validators only check them when asked, but they document the intent well. If your strings only look like dates by chance, switch detection off.
A generated schema is a starting point, not a finished contract. It cannot know your rules: that a price is never negative, that status is one of three words, or that extra keys are forbidden. It allows extra keys, which is the JSON Schema default. Add enum, minimum, pattern and additionalProperties where they matter. Everything runs in this page, so you can build a schema from production data without sending that data anywhere.