JSON to JSON Schema Generator
: Infer a JSON Schema from sample data and edit its attributes visuallyLimits: 50 MB · JSON Schema draft 2020-12. After generation, sample changes only update validation; your schema edits stay. Large numbers use JavaScript precision.
JSON Schema
Generate a schema to inspect its fields.
JSON to JSON Schema Generator
Turn example data into a draft 2020-12 schema, then select fields in a tree to refine their types, annotations and constraints. Use it to draft an API contract or a validation rule set when you have representative JSON but no schema yet.
How to build a JSON Schema from JSON
- Put data in the
JSON samplepane: type it, pressPaste(or Ctrl+V anywhere on the page), pressOpen fileor drop a file, or pressExample. - Press
Generate schema. The tree shows inferred fields, types and required properties. - Select a field, edit its attributes and press
Apply attributes. Required property controls presence; nullable controls whether its value may be null. - Review the validation results under the attributes. Change the sample to test other values without overwriting your schema edits.
- Switch to
Sourceto inspect the JSON, thenCopyit orDownloadschema.json.Regenerate schemastarts again from the current sample and replaces your edits.
Example
Both array entries contribute fields; note is optional because only one entry includes it.
[{"id":1,"note":"Gift"},{"id":2}]{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"note": {
"type": "string"
}
},
"required": [
"id"
]
}
}Details
- Inference inspects every array entry. Object properties are combined and a property is required only when every observed object at that location includes it. Mixed values use a type list; integer and number combine into number.
- An empty array gets an unconstrained items schema. A null-only value gets type null: select its intended type and leave nullable checked if it should also accept null. No enum, format, range or string pattern is guessed from a single example.
- Attributes include title, description, enum, default, examples, string format and pattern, length bounds, numeric bounds and multipleOf, array bounds and uniqueness, and additional properties. Enum and examples take JSON arrays; default takes any JSON value. Annotations do not fill in missing data.
- Property names such as @id, attributes, constructor and __proto__ remain ordinary JSON keys.
- Validation uses @cfworker/json-schema in a local browser worker. Patterns and formats are checked by that library; unknown formats are ignored. The exported schema permits extra object properties until you turn off allow additional properties.
Limits
- Large samples with any number of values work, and opened files can be up to 50 MB. Over 1,000,000 characters,
Generate schemareads the sample in a background worker with a progress line andCancel, and a changed sample waits forValidate sample. Nesting is limited only by the browser's call stack; JSON nested deeper than it allows gets an error that says so. JSON numbers use JavaScript precision, so integers beyond the safe integer range may be rounded. Duplicate object names use their last value. - The tree shows up to 1,000 visible fields; collapse branches to reach more. The source and download include all fields. Validation runs to the end in the worker, with
Cancelwhen it takes a while, and lists every issue: the first 2,000 at once, more withShow more, andCopy issuescopies them all. - Source is a read-only preview. This builder does not import existing schemas, create references, infer conditional rules or prove that an example captures all valid data. Review required fields and types against your actual contract.
- Edits live in this page only. Copy or download the schema before leaving or reloading.
FAQ
Does changing my JSON sample regenerate the schema?
No. Sample edits only rerun validation against the current schema. Press Regenerate schema when you want to replace it with a new inference.
Can a required property also be nullable?
Yes. Required means the key must be present; nullable allows its value to be null. For example, a required nullable string accepts a present null value but rejects an absent property.
Runs entirely in your browser. Nothing is uploaded.