How to Generate a JSON Schema Online
JSON Schema is a vocabulary for describing the expected structure of JSON data. Teams use schemas to document API payloads, validate configuration files, check incoming data and communicate the shape of objects between services. A JSON Schema Generator creates a useful first draft from an example JSON object or array.
How to use this JSON Schema Generator
- Prepare a valid JSON example that represents the data you expect to receive.
- Paste it into the input box or select Load example.
- Set a schema title, such as
UserProfileorApiResponse. - Choose whether to infer required properties and whether to disallow additional properties.
- Select Generate Schema, review the result, and copy or download the JSON file.
How required properties are inferred
When required-property inference is enabled, a property is marked required if it appears in every sampled object at that level. For objects inside an array, the generator compares the keys in the sampled objects. A small sample can miss fields or variations that appear in real data, so use representative examples and review the required list carefully.
Nested objects, arrays, nulls and mixed values
Nested objects are described through nested properties. Arrays receive an items schema inferred from their elements. If a value appears as more than one type in the sample, the schema uses anyOf to represent those alternatives. Null is represented as a type alternative. Empty arrays do not reveal the intended item structure, so their item schema remains broad.
Additional properties and strict validation
By default, JSON objects may contain keys beyond those listed in the schema. The optional strict setting adds "additionalProperties": false to generated object schemas. Enable it only when extra keys should genuinely be rejected; otherwise it may reject valid data added by another API version.
A generated schema is a starting point
Examples reveal structure, not every business rule. Review date and time formats, numeric ranges, string patterns, unique identifiers, conditional requirements and versioning needs. The generated schema does not automatically prove that a payload is valid; run a compatible JSON Schema validator against the actual data.
Related CSV and JSON developer tools
Inspect and correct your input with the JSON Formatter and Validator, compare sample payloads using JSON Diff & Compare, or generate static types with JSON to TypeScript. You can also convert data using CSV to JSON, JSON to CSV, JSON to YAML, JSON to XML and JSON to TOML.