All Technologies
Frameworks·expert

Zod

TypeScript-first schema validation

Zod is how I validate untrusted input in TypeScript. Schemas are code, infer their own types, and integrate cleanly with forms, APIs, and LLM outputs.

3+years in production
50+projects shipped
expertproficiency

My take

Why I use Zod

Zod erases the gap between runtime values and compile-time types. I use it on every trust boundary - HTTP inputs, environment variables, LLM tool calls - to keep bad data from leaking into the type system.

Want the broader stack philosophy? Read about how Sri picks tools or browse engineering insights.

Honest assessment

Strengths & tradeoffs

No tool is perfect. Here's what shines and what to watch for.

Strengths

  • Schema and type live in the same definition
  • Composable, refinable schemas
  • Excellent error messages
  • Integrates with React Hook Form, tRPC, OpenAI structured outputs
  • Runtime guarantees that match static types

Tradeoffs (honestly)

  • Bundle size larger than Valibot or ArkType
  • Heavy schemas can hurt cold-start in serverless
  • Some advanced TS features push compile times

Fit assessment

When to reach for Zod

Pick the right tool for the job.

Best fits

Validating API request bodies

Form validation with React Hook Form

Parsing env vars on boot

Structured outputs from LLMs

Trust boundaries between subsystems

Not ideal for

Hot paths where validation cost matters (consider Valibot)

Languages other than TypeScript

Common use cases

API input validationForm validationLLM structured outputEnv var parsing

Resources

Learn more

Curated official docs, tutorials, and writing on Zod.

Need help with Zod?

Whether you're starting fresh or optimizing an existing implementation, I can help you get the most out of this technology. Read more in insights or get in touch.

Command Palette

Search for a command to run...