What problem does it solve?
Zod eliminates the gap between TypeScript’s compile-time types and untrusted runtime data by validating API payloads, env vars, and form inputs while producing precise, per-field error reports.
Core Features & Use Cases
- Runtime schema validation: Define Zod 4 schemas for objects and primitives, then parse or safely parse untrusted input without silent failures.
- Transforms, refinements, and async validation: Normalize and convert values (e.g., coerce env/query data), enforce cross-field rules, and run async checks safely with parseAsync/safeParseAsync.
- Discriminated unions and composition: Model tagged unions/state machines with z.discriminatedUnion, compose schemas with extend/merge/pick/omit/partial, and reuse types via z.infer.
Quick Start
Ask the AI to build a Zod 4 schema for my request body with strict mode, safeParse error flattening, and a typed output using z.infer.