# Zod — TypeScript-First Schema Validation > TypeScript-first schema declaration and validation library. Define a schema once, get type inference, runtime validation, and serialization. The standard for TypeScript data validation. 35,000+ stars. ## Install Save as a script file and run: ## Quick Use ```bash npm install zod ``` ```typescript import { z } from "zod"; const UserSchema = z.object({ name: z.string().min(2), email: z.string().email(), age: z.number().int().min(0), role: z.enum(["admin", "user"]), }); type User = z.infer; const user = UserSchema.parse(data); ``` --- ## Intro Zod is a TypeScript-first schema declaration and validation library with 35,000+ GitHub stars. Define a schema once and get both TypeScript type inference and runtime validation. Used by tRPC, Vercel AI SDK, React Hook Form, and Drizzle ORM. Best for TypeScript developers who want type-safe validation at API boundaries. Works with: any TypeScript project. Setup time: instant. --- ## Core Features ### Type Inference from Schema ```typescript const Schema = z.object({ name: z.string(), age: z.number() }); type T = z.infer; // { name: string; age: number } ``` ### API Validation ```typescript const body = CreatePostSchema.parse(await req.json()); ``` ### AI SDK Integration ```typescript 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. --- ## Source & Thanks > Created by [Colin McDonnell](https://github.com/colinhacks). Licensed under MIT. > > [zod](https://github.com/colinhacks/zod) — stars 35,000+ --- ## 快速使用 ```bash npm install zod ``` ```typescript import { z } from "zod"; const Schema = z.object({ name: z.string(), email: z.string().email() }); type T = z.infer; ``` --- ## 简介 Zod 是 TypeScript 优先的数据验证库,GitHub 35,000+ stars。一次定义 schema,同时获得类型推断和运行时验证。 --- ## 来源与感谢 > Created by [Colin McDonnell](https://github.com/colinhacks). Licensed under MIT. > > [zod](https://github.com/colinhacks/zod) — stars 35,000+ --- Source: https://tokrepo.com/en/workflows/5328f7ec-37d8-47bc-afb5-034b66d1537d Author: Script Depot