What problem does it solve?
Zod prevents runtime type drift by turning unknown inputs into well-typed values at trust boundaries, so your code stops guessing and fails fast with structured errors.
Core Features & Use Cases
- Schema-first parsing: define types once and parse
unknown into a concrete, inferred TypeScript type.
- Trust-boundary validation: validate form inputs, Express request bodies/queries, environment variables at boot, and API/LLM payloads with
safeParse at request time.
- Composable validation: build robust schemas using objects, unions (including discriminated unions), refinements, transforms, coercion, branding, and consistent error formatting via
flatten() / format().
Quick Start
Use zod to safely parse an incoming request body with a shared schema: ask the AI to generate a Zod schema and an Express middleware that returns a 400 with error.flatten().fieldErrors on invalid input.