zod
Use when working with Zod for schema validation — form validation, API input parsing, environment variable validation, or TypeScript type inference from schemas. Also use when choosing a validation library or debugging Zod type errors.
| Model | Source |
|---|---|
| sonnet | pack: forms |
Full Reference
┏━ 🔧 zod ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Use when working with Zod for schema validatio… ┃ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Zod v4 is a TypeScript-first schema validation library with static type inference. v4 (released July 2025) ships 14x faster string parsing, a ~57% smaller bundle vs v3, and top-level format validators like z.email() and z.url(). v3 is still available at the "zod": "^3" package root; v4 is the new default.
Quick Reference
Section titled “Quick Reference”| Item | Value |
|---|---|
| Current Version | 4.3.6 (stable, February 2026) |
| Install | npm install zod |
| Import | import { z } from "zod" |
| v4 subpath | import { z } from "zod/v4" |
| Mini (tree-shakable) | npm install @zod/mini (~1.9 KB gz) |
| TypeScript requirement | v5+ recommended |
| Docs | https://zod.dev |
Reference Index
Section titled “Reference Index”| I want to… | File |
|---|---|
| Define primitives, objects, arrays, enums, and composition patterns | reference/schemas.md |
| Parse and validate data, infer types, or validate env vars and API inputs | reference/parsing.md |
| Handle ZodError, format errors, or write custom error messages | reference/error-handling.md |
| Transform, refine, pipe, or coerce values | reference/transforms.md |
| Use unions, discriminated unions, recursive schemas, branded types, or migrate from v3 | reference/advanced-types.md |
Usage: Read the reference file matching your current task from the index above. Each file is self-contained with code examples and inline gotchas.