Skip to content
Free Tool Arena

Glossary · Definition

JSON Schema

JSON Schema is a vocabulary for describing the structure of valid JSON: required fields, types, allowed values, nested-object shape. Use it for API request validation, OpenAPI docs, and structured data validation. Modern alternatives: TypeScript types (for compile time), Zod / Yup / Valibot (for runtime validation in JS).

Updated June 2026 · 4 min read
100% in-browserNo downloadsNo sign-upMalware-freeHow we keep this safe →

Definition

JSON Schema is a vocabulary for describing the structure of valid JSON: required fields, types, allowed values, nested-object shape. Use it for API request validation, OpenAPI docs, and structured data validation. Modern alternatives: TypeScript types (for compile time), Zod / Yup / Valibot (for runtime validation in JS).

What it means

JSON Schema is itself written in JSON. Example: <code>&#123;&quot;type&quot;: &quot;object&quot;, &quot;required&quot;: [&quot;name&quot;], &quot;properties&quot;: &#123;&quot;name&quot;: &#123;&quot;type&quot;: &quot;string&quot;&#125;, &quot;age&quot;: &#123;&quot;type&quot;: &quot;integer&quot;, &quot;minimum&quot;: 0&#125;&#125;&#125;</code> says &ldquo;name is required string, age is non-negative integer.&rdquo; The Draft 2020-12 spec is current; Draft 7 is widely supported. Validators exist in every major language (Ajv for JavaScript, jsonschema for Python, Pydantic for Python with auto-generation). OpenAPI specs use JSON Schema for request/response validation. Modern JS alternatives (Zod, Yup, Valibot) write validation in the language directly with auto-inferred TypeScript types — often more ergonomic than separate JSON Schema files.

Advertisement

Why it matters

Strict JSON catches syntax errors but not semantic errors. <code>&#123;&quot;userId&quot;: &quot;abc&quot;&#125;</code> is valid JSON but invalid in an API expecting numeric ID. JSON Schema catches that. For REST/GraphQL APIs: documenting expected shape via OpenAPI lets clients verify contracts before deployment. For form validation: schema-based validation centralizes rules in one place. For data-pipeline ETL: schema validation catches malformed data before it propagates.

Example

Schema: <code>&#123;&quot;type&quot;: &quot;object&quot;, &quot;required&quot;: [&quot;email&quot;], &quot;properties&quot;: &#123;&quot;email&quot;: &#123;&quot;type&quot;: &quot;string&quot;, &quot;format&quot;: &quot;email&quot;&#125;&#125;&#125;</code>. Valid: <code>&#123;&quot;email&quot;: &quot;a@b.com&quot;&#125;</code>. Invalid: <code>&#123;&quot;email&quot;: 42&#125;</code> (wrong type), <code>&#123;&#125;</code> (missing required), <code>&#123;&quot;email&quot;: &quot;not-an-email&quot;&#125;</code> (format violation).

Related free tools

Frequently asked questions

JSON Schema vs Zod vs Pydantic?

JSON Schema: language-neutral, written in JSON. Zod (JS/TS), Pydantic (Python), Joi (older JS): language-native, more ergonomic for that language but not portable. Modern apps often use Zod for runtime validation + auto-generate JSON Schema for OpenAPI docs.

What versions exist?

Drafts 4, 6, 7, 2019-09, 2020-12 (current). Most validators support Draft 7+. Differences are minor for most use cases.

Can I auto-generate schemas from data?

Yes — tools like quicktype.io infer schema from sample JSON. Useful starting point but typically needs manual refinement (sample data may not capture edge cases or required fields).

Related terms

Found this useful?

The tools stay free thanks to readers who chip in or spread the word.

Buy Me a Coffee