ScriptsApr 7, 2026·1 min read

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.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

npm install zod
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<typeof UserSchema>;
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

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.


🙏

Source & Thanks

Created by Colin McDonnell. Licensed under MIT.

zod — stars 35,000+

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets