What is JSON Schema?
JSON Schema is a vocabulary for annotating and validating JSON documents. It defines the expected structure, types, and constraints of your data. Draft-07 is the most widely supported version, compatible with AJV, Joi, Fastify, OpenAPI 3.0, and more.
Why Generate Schemas from Sample JSON?
Writing JSON Schema by hand is tedious and error-prone. Our generator infers the schema directly from your sample payload — perfect for documenting APIs, validating incoming data, or creating OpenAPI spec components.
Schema Inference Rules
- Every key becomes a property with an inferred
type - All keys present in the sample are added to
required - Nested objects generate nested
$defsreferences - Arrays infer
itemstype from the first element - Null values generate
["string", "null"]union types
// JSON Input
{ "id": 1, "name": "Alice", "email": "a@example.com", "active": true }
// Generated JSON Schema (Draft-07)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["id", "name", "email", "active"],
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string" },
"active": { "type": "boolean" }
}
}