JSON to JSON Schema
Paste a JSON object or array and get a JSON Schema — types, required fields, unions, and string formats inferred. Draft 2020-12 or Draft-07. Runs in your browser, nothing is uploaded.
About this tool
JSON to JSON Schema infers a practical JSON Schema from one pasted JSON example or from an array of examples. It is useful when you have sample API responses, config objects, event payloads, or webhook fixtures and want a starting schema without writing every property by hand.
- Objects and arrays are inferred recursively: nested objects become
properties, arrays becomeitems, and arrays with several objects merge the observed item shapes. - Required keys are data-driven: keys present in every merged object are
listed under
required; keys missing in some examples become optional. - Mixed values become unions: for example
[1, "two"]produces an item type that accepts bothintegerandstring. - String formats are detected when enabled: email, URI, date-time, date, UUID (Draft 2020-12), and IPv4.
- Strict by default:
additionalProperties: falseis emitted unless you turn on “Allow extra properties”.
Everything runs locally in your browser through WebAssembly. Your sample JSON is not uploaded.
Worked example
Input:
[{ "id": 1, "email": "[email protected]" }, { "id": 2, "email": "[email protected]", "admin": true }]
Output excerpt:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"admin": { "type": "boolean" },
"email": { "type": "string", "format": "email" },
"id": { "type": "integer" }
},
"required": ["email", "id"],
"additionalProperties": false
}
}
Limits & edge cases
- This is inference, not proof. A small sample may miss optional fields, allowed enum values, minimums, maximums, string lengths, or domain-specific rules.
- Empty arrays infer
items: {}because there are no elements to learn from. - Incompatible shapes (for example sometimes an object and sometimes a string) are intentionally widened rather than guessed narrowly.
- It does not validate future JSON against the schema; use the generated schema in your validator of choice.
FAQ
Can I infer from more than one example?
Yes. Paste a JSON array of example objects. The tool merges the item schemas: properties seen in every object stay required, while properties missing from at least one object become optional.
Why did a field become optional?
A property is required only when it appears in every merged object at that level.
If one sample omits it, the generated schema still includes the property type but
leaves it out of the required array.
What does “Allow extra properties” change?
By default the schema is strict and emits additionalProperties: false on
objects. Turning this option on omits that keyword, allowing validators to accept
keys that were not present in the sample.
Which JSON Schema drafts are supported?
The tool emits either Draft 2020-12 (default) or Draft-07. Draft choice changes
the $schema URI; UUID format detection is emitted only for Draft 2020-12 because
Draft-07 did not define a uuid format.
Does this replace reviewing the schema manually?
No. It creates a solid starting point from observed data, but you should still review business rules such as enumerations, numeric bounds, string lengths, patterns, and fields that did not appear in your examples.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool json-to-json-schema "{ "name": "Ada", "email": "[email protected]", "roles": ["admin"] }"New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/json-to-json-schema/?json=%7B%20%22name%22%3A%20%22Ada%22%2C%20%22email%22%3A%20%22ada%40example.com%22%2C%20%22roles%22%3A%20%5B%22admin%22%5D%20%7D&draft=2020-12&additional_properties=true&required=true&detect_formats=true&title=UserMachine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
