Skip to Content
advanced-8y4qeprJson Schema

Last Updated: 3/12/2026


JSON Schema

Zod can convert schemas to JSON Schema format for use with other tools and documentation generators.

Basic Conversion

import * as z from "zod"; const User = z.object({ name: z.string(), age: z.number().int().positive(), }); const jsonSchema = User.toJSONSchema(); /* { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer", "minimum": 1 } }, "required": ["name", "age"] } */

Descriptions

Add descriptions for documentation:

const User = z.object({ name: z.string().describe("The user's full name"), age: z.number().describe("Age in years"), }).describe("A user account"); const jsonSchema = User.toJSONSchema();

Limitations

Not all Zod features map to JSON Schema:

  • Transforms are not representable
  • Refinements may not convert
  • Async validation cannot be expressed

For these cases, the JSON Schema represents the input type before transforms/refinements.

What’s Next