Generate JSON Schema from Complete JSON Examples
Generate a JSON Schema from your examples. Review which fields are required, check the samples and download the schema.
Tool workspace
JSON Schema Generator
Enable JavaScript to infer a schema locally in your browser.
Each editor is one complete JSON document. A root array stays an array. Examples guide the schema; they do not prove the rules of your domain.
Up to 20 samples; 250,000 UTF-16 units per sample, 500,000 in total; 1,000,000 bytes per file; depth 20; 50,000 source nodes in total; 2,000 inferred nodes; schema up to 100,000 UTF-16 units. Work budgets can be reached before these sizes.
Processing stays in your browser. Samples are not uploaded or saved.
1 sample(s).
Enter JSON in every sample.
Additional diagnostics were omitted because a diagnostic budget was reached.
This browser cannot start a Worker. Try a supported browser to process samples locally.
Inferred fields and types
Null is a present value; it does not make a field optional. Presence is measured only among objects at that location.
Object and array branches are combined. The schema can accept additional combinations because relationships between fields are not inferred.
No format candidates on this page.
Suggestions require at least two strings, each at most 1,024 UTF-16 units, and no counterexample. Duplicate examples still count as observations. Formats are not emitted or validated in v1.
The schema does not accept all samples. Copy and download include the complete schema with your manual required rules.
Sample compatibility
Manual copying
Select the complete output and copy it with your keyboard. Close this help to return to the Copy button.
Copy the schema and paste it into the validator manually. These links do not transfer samples or the schema.
Analyze documents before generating
Paste a complete JSON document into each editor or open a local UTF-8 .json file. Add up to twenty samples, choose Analyze samples, review the fields, then select Generate schema.
Every sample must be valid strict JSON. Fix empty editors, duplicate keys, comments, JSONC/JSON5 or numbers that lose precision before continuing; the tool does not silently skip a failing sample.
An array in one editor is one sample, and all of its elements contribute to the schema. Multiple editors produce one schema for their documents. A sample can also be a string, number, boolean or null.
The array example is:
[{"id":1},{"id":2,"nombre":"Ana"}]
With inferred required fields, the complete array passes this schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"nombre": {
"type": "string"
}
},
"required": [
"id"
],
"additionalProperties": true
}
}
Decide which fields are required
In the example, id appears in both objects, so it is required by default. nombre appears in only one and is optional. If you mark nombre as required, the first object no longer passes: the report points to /0, with required at /items/required. You can still export the schema, but it will warn that some samples do not match.
A missing property and a property set to null mean different things. In [{"x":null},{"x":"a"},{}], x is optional and accepts either null or a string. Remove the empty object, and x becomes required while still accepting null.
Required fields are inferred from the examples you supply, not from your application’s rules. For nested objects, only objects at the same location are compared. Review the choices before using the schema. Resetting inferred required fields clears all your manual choices, including those on other pages.
An empty array [] produces type: "array" with items: {}, because it gives no evidence about its elements. An empty object {} reveals no properties. Integers and fractions combine as number; other mixed types form a type union. The schema can therefore accept combinations that did not occur in your examples.
What the generated schema checks
The output uses JSON Schema draft-07. It describes types, object properties, required fields and array items. Objects allow extra properties through additionalProperties: true. You can add a root title and description.
It does not infer enums, numeric ranges, patterns, references, tuples or conditions using anyOf, oneOf or allOf. Add those rules yourself if your application needs them.
Optional format suggestions can identify ASCII email addresses, absolute HTTP(S) URIs and dates written as YYYY-MM-DD. Enable them before analyzing. At least two string observations must match; a counterexample or a string over 1,024 UTF-16 units removes the suggestion. Suggestions do not add a format rule to the schema, and the built-in checker does not validate formats.
Exporting and working within the limits
Copy or download exports the complete schema, regardless of which field page you are viewing. The download is schema.json, with MIME type application/schema+json, in UTF-8 without BOM. You can choose two or four spaces of indentation. Line endings are LF, with no final newline. If clipboard access fails, copy from the full read-only output.
| Limit | Maximum |
|---|---|
| Samples | 20 |
| File size | 1,000,000 bytes |
| Text per sample / total | 250,000 / 500,000 UTF-16 units |
| Nested containers per sample | 20 levels |
| Values per sample / total | 25,000 / 50,000 |
| Inferred properties | 2,000 |
| Schema text | 100,000 UTF-16 units |
| Title / description | 256 / 2,000 UTF-16 units |
| Analysis or generation time | 8 seconds |
Complex samples or very long field names can reach processing limits sooner. A failed or canceled operation produces no partial schema. The field list shows up to 25 entries per page.
Files must use UTF-8. One initial BOM is removed with a notice; a second is invalid. Editing the samples or format suggestions requires a fresh analysis and resets your required-field choices. Changing required fields or schema options requires generating the output again.
Processing stays in a local Worker and requires JavaScript. Samples are not uploaded or stored. To use the related validator, copy and paste the schema yourself; links do not transfer your data.