JSON Schema from sample.
Paste a JSON document, get a Draft 2020-12 or draft-07 schema describing it. Detects date-time email uri uuid ipv4 formats, merges arrays of objects into a union, and intersects required-keys across multiple samples. Use as a starting point — then tighten by hand.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"active": {
"type": "boolean"
},
"joined": {
"type": "string",
"format": "date-time"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"address": {
"type": "object",
"properties": {
"city": {
"type": "string"
},
"zip": {
"type": "string"
}
},
"required": [
"city",
"zip"
],
"additionalProperties": false
}
},
"required": [
"id",
"name",
"email",
"active",
"joined",
"tags",
"address"
],
"additionalProperties": false
}A schema is a contract you can test against.
JSON Schema's value isn't documentation — it's executable contracts. Generate the schema once from real samples, validate every incoming and outgoing message against it in CI, and you catch shape regressions before they reach production. OpenAPI specs are JSON Schemas under the hood; AsyncAPI uses them for event payloads; ajv compiles a schema down to a JIT-validated function that runs in a few hundred nanoseconds. The thing to avoid is keeping the schema as a one-off artefact that drifts; bake it into the dev loop, even just as a git-tracked file you regenerate when something breaks.
Draft 2020-12 is the current spec. draft-07 is the most widely supported in older tooling — OpenAPI 3.0 used it directly. If you're starting fresh, use 2020-12. If you're bolting onto an OpenAPI 3.0 system, stay on draft-07 to avoid validator mismatches.