Skip to main content
The Schema module provides utilities for converting Zod schemas to JSON Schema objects, useful for generating documentation, API specs, or validation schemas.

Functions

toJsonSchema

Converts a Zod schema to a JSON Schema object, stripping the $schema meta-property.
schema
z.ZodType
required
The Zod schema to convert to JSON Schema format
return
Record<string, unknown>
A JSON Schema object representation of the Zod schema, with the $schema property removed

Usage

Example: Generate OpenAPI Schema

Example: CLI Help Schema