JSON Schema Cheat Sheet
A reference for defining and validating JSON document structure using JSON Schema keywords, types, and constraints.
2 PagesIntermediateFeb 8, 2026
Basic Schema Structure
A minimal object schema with type and required fields.
json
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Person", "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer", "minimum": 0 }, "email": { "type": "string", "format": "email" } }, "required": ["name", "age"], "additionalProperties": false}
String & Number Constraints
Common validation keywords for primitive types.
json
{ "username": { "type": "string", "minLength": 3, "maxLength": 20, "pattern": "^[a-zA-Z0-9_]+$" }, "price": { "type": "number", "minimum": 0, "exclusiveMaximum": 10000, "multipleOf": 0.01 }, "status": { "type": "string", "enum": ["active", "inactive", "pending"] }}
Arrays & Composition
Array validation and combining schemas.
json
{ "tags": { "type": "array", "items": { "type": "string" }, "minItems": 1, "uniqueItems": true }, "contact": { "oneOf": [ { "type": "string", "format": "email" }, { "type": "string", "format": "uri" } ] }, "discountedPrice": { "allOf": [ { "type": "number" }, { "minimum": 0 } ] }}
Key Keywords Reference
Frequently used JSON Schema keywords and what they do.
- type- Restricts value to one of: string, number, integer, boolean, object, array, null
- required- Array of property names that must be present on an object
- enum- Value must exactly match one of the listed values
- $ref- References another schema, e.g. `#/definitions/Address` or a `$defs` entry
- anyOf / oneOf / allOf- Value must match at least one, exactly one, or all listed subschemas
- additionalProperties- `false` disallows properties not listed in `properties`
- format- Semantic hint like `date-time`, `email`, `uri` (validated by some validators, advisory in others)
Pro Tip
Set `additionalProperties: false` on objects you fully control to catch typos in payloads early, but leave it open on schemas meant to be extended by consumers to avoid breaking forward compatibility.
Was this cheat sheet helpful?
Explore Topics
#JSONSchema#JSONSchemaCheatSheet#ToolsOthers#Intermediate#BasicSchemaStructure#StringNumberConstraints#ArraysComposition#KeyKeywordsReference#Databases#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance