Generate a starter JSON Schema from a representative sample
The Schema Generator infers a starter Draft 7 schema from observed JSON values. It saves the first pass of describing nested object and array shapes.
When should you use it?
- Start an API response contract.
- Document the shape of a configuration example.
- Create a draft to refine in the Schema Validator.
Example: infer fields from one record
The tool marks both observed fields required. Remove a field from required if the real contract allows it to be absent.
{"name":"Alex","active":true}{"type":"object","properties":{"name":{"type":"string"},"active":{"type":"boolean"}},"required":["name","active"]}A sample describes what happened, not everything allowed
An example containing an integer quantity shows one observed type. It cannot tell the generator whether negative quantities are permitted, whether the field is optional, or whether a status has only three allowed values. Inference is useful for drafting the shape of nested objects and arrays, but business rules still need to be written by someone who knows the contract.
Turn the generated draft into a tested contract
Review required fields, nullable values, array item types, and additional properties. Add constraints such as minimum, minLength, and enum only when they reflect a real requirement. Then open the validator and try both valid and invalid payloads. An empty array or a field that is always null in the sample gives little evidence about future values; use a more representative example where possible.
Start a schema from real data.
Infer the observed JSON types, object properties, required names, and array item shapes. Then edit the generated Draft 7 schema for your actual contract.
Paste a representative sample
Use valid JSON without duplicate object names.
Generate the draft
The output reflects observed types and nested structure.
Review the contract
Remove accidental required fields and add business rules before validation.
How do I generate a starter JSON Schema from one API response?
Paste a representative response and generate Draft 7 schema text. The draft records observed types, nested properties, and array item shapes. Review required fields carefully: a property seen in the sample may still be optional in real responses.
Sample object and a requirement to review
json{"id":7,"nickname":"Alex"}Both id and nickname are observed. The generated required list includes both, even if nickname is optional in your actual API.
Can inference discover ranges or fields absent from the sample?
No. Add rules such as minimum, pattern, and descriptions yourself, and test more than one valid and invalid instance in the Schema Validator.
What should you check before using the result?
One sample cannot reveal optional fields, unseen alternatives, patterns, ranges, or intended descriptions. Empty arrays have unrestricted item shapes; inference stops after 5,000 values.
What inference can and cannot know
A property present in one sample is marked required. An absent property cannot be discovered. The tool does not invent formats, patterns, minimums, or descriptions. Compare the draft with multiple real cases and use the JSON Schema validator to test it.
Large integers and arrays
Integer-looking number tokens are classified without converting their value to a JavaScript number. Array item types are merged from the sample; empty arrays have unrestricted items. Inference stops after 5,000 values.
Technical reference: JSON Schema Draft 7 validation specification