Core Features
Type Inference from Schema
const Schema = z.object({ name: z.string(), age: z.number() });
type T = z.infer<typeof Schema>; // { name: string; age: number }API Validation
const body = CreatePostSchema.parse(await req.json());AI SDK Integration
const { object } = await generateObject({
model: anthropic("claude-sonnet-4-20250514"),
schema: z.object({ summary: z.string(), keywords: z.array(z.string()) }),
prompt: "Analyze...",
});Key Stats
- 35,000+ GitHub stars
- Zero dependencies, 12KB
- Used by tRPC, AI SDK, React Hook Form
FAQ
Q: What is Zod? A: TypeScript-first schema library providing both compile-time type inference and runtime validation from a single schema definition.
Q: Is Zod free? A: Yes, MIT license.