Embed this tool on your site
About this tool
The JSON Schema Generator from Sample reads one JSON document and infers a Draft-07 JSON Schema that describes its shape. It detects the types string, number, integer, boolean, null, array and object, recurses into nested objects and arrays, and lists every key of each object it sees under required. Strings get format hints when they look like a date-time (YYYY-MM-DDT...), a date (YYYY-MM-DD), an email address or an http(s) URL. For an array whose items share one type, the schema of the first item is used for all items; mixed-type arrays become a oneOf of the first three item schemas. Results appear in an output panel with Copy schema and Download (schema.json) buttons. The output is a starting point to refine by hand with descriptions, enum, length limits or additionalProperties. Everything runs in your browser.
Why use it
Generates a JSON Schema skeleton in seconds from real data — no manual writing.
Infers types, nested object structure and array item schemas automatically.
Adds format hints for date-time, date, email and URL strings.
Dramatically reduces the manual work of bootstrapping schema development.
How to use
- Paste your sample JSON document into the Sample JSON panel, or click Load sample.
- Click Infer Schema — the Draft-07 schema appears in the output panel.
- Check the required lists and array item schemas, which come from the first object or item in each array.
- Click Copy schema or Download to save it as schema.json.
- Refine the schema in your codebase, then validate new data with the JSON Schema Validator.
When it helps
- Bootstrapping a JSON Schema for an existing API that lacks documentation.
- Creating a starting schema from a sample API response to validate against in tests.
- Generating schemas for configuration files to enable editor validation (VSCode, IntelliJ).
- Documenting data structures for team sharing or API contracts.
Examples
Input{ "id": 1, "name": "Ada", "email": "ada@example.com", "active": true }
Expected result · Scroll for more{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"active": {
"type": "boolean"
}
},
"required": [
"id",
"name",
"email",
"active"
]
}
Input{ "tags": ["alpha", "beta", "gamma"] }
Expected resulttags: { "type": "array", "items": { "type": "string" } }, and "tags" is listed under required.
03Array of objects (first item only)
Input[ {"id": 1, "name": "A"}, {"id": 2, "name": "B", "archived": true} ]
Expected result · Scroll for more{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}
}
04Date-time and date detection
Input{ "createdAt": "2024-05-08T14:30:00Z", "birthDate": "1990-05-15" }
Expected result · Scroll for more{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"createdAt": {
"type": "string",
"format": "date-time"
},
"birthDate": {
"type": "string",
"format": "date"
}
},
"required": [
"createdAt",
"birthDate"
]
}
Tips
- Put the most complete object first in an array — only the first item is analyzed when all items share a type.
- After generation, manually add 'description' fields to every property — they appear in IDE tooltips and improve developer experience hugely.
- Add additionalProperties: false by hand to objects that should reject unknown keys.
- Replace inferred string types with enum where the value set is closed (e.g. status: 'active' | 'archived').
- Add minLength, maxLength, minimum, maximum, pattern constraints based on your domain knowledge — the generator infers structure but not business rules.
- Before publishing the schema, validate it against your sample data using the JSON Schema Validator — catch any gaps from the inference.
Frequently Asked Questions
Is the generated schema production-ready?⌄
The schema accurately reflects the structure of the sample data but is intentionally permissive. You should add constraints (minLength, enum, format, additionalProperties: false) before using it in production.
How does it determine which fields are required?⌄
Every key present in an object is listed as required. In arrays of objects only the first object is analyzed, so remove keys from required by hand when they are optional.
Does it handle arrays with mixed types?⌄
Partly. A mixed-type array gets items: { oneOf: [...] } built from the first three item schemas. Because oneOf demands exactly one match, an array such as [1, 2.5] or [1, "a", 2] produces a schema that rejects its own sample; change oneOf to anyOf or a type list.
Can I provide multiple sample objects?⌄
You can paste an array, but samples are not merged. When the items share a type, the schema of the first item is used, so keys that only appear in later items are left out.
Does it infer format keywords like date-time or email?⌄
Yes, for four patterns: strings starting YYYY-MM-DDT get date-time, YYYY-MM-DD gets date, simple name@domain.tld strings get email, and http:// or https:// strings get uri. These are hints, not guarantees.
Why does my schema mark a field as 'integer' when sometimes it's a float?⌄
Whole numbers infer integer. Inside an array of objects only the first object is read, so if it has a whole number and a later one has a decimal, edit the type to number by hand.
How do I close the schema to reject unknown fields?⌄
Add "additionalProperties": false to each object schema after generating. The tool does not add it for you.
Which draft is the output?⌄
Always Draft-07; the output starts with "$schema": "http://json-schema.org/draft-07/schema#". There is no Draft-2020-12 option.
Glossary
- Schema inference
- The process of analyzing data and deriving a structural description (schema) from it. The output describes the shape of the data but not its semantic constraints.
- Required vs optional
- In JSON Schema, properties listed under 'required' must be present. Properties under 'properties' but not in 'required' are optional. This tool lists every key it sees as required.
- Draft-07
- A widely adopted JSON Schema specification version. Most tooling (Ajv, AsyncAPI 2.x, OpenAPI 3.0) supports it natively.
- Draft-2020-12
- The current JSON Schema specification. Adds prefixItems, refined $ref behavior, and unevaluatedProperties. Recommended for new projects when tooling supports it.
- additionalProperties
- Schema keyword that controls whether objects may contain unknown properties. Set to false for strict contracts; set to a schema to validate unknown properties.
- Type coercion
- JSON Schema does not coerce types. The inferred type from sample '5' (string) will be 'string', not 'number'. Refine manually if the runtime should treat it as numeric.
- Format keyword
- Annotates strings with semantic types (email, uri, date-time, uuid). Inferred from common value patterns; validation may be assertive or informational.
- Heterogeneous array
- An array containing items of different types. A schema usually describes it with anyOf or a list of types so each item can match at least one option.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities