Schema validation libraries ensure your runtime data matches your TypeScript types. Zod is the current king, Yup is the legacy standard, and Valibot is the new lightweight challenger. Here's which one validates best in 2026.

Quick Comparison

ZodYupValibot
Bundle size~12KB~8KB~2KB (modular)
TypeScript inferenceExcellent (z.infer)Good (InferType)Excellent (v.InferOutput)
API styleChained methods (z.string().email())Chained methods (string().email())Functional (v.pipe(v.string(), v.email()))
Tree-shakableLimitedNoYes (every function is a named export)
Ecosystem sizeLargest (tRPC, react-hook-form, etc.)Large (Formik, RHF)Growing
Async validationYes (z.string().refine(async))YesYes

Zod — The Ecosystem Standard

Zod is the most popular schema validation library by a wide margin. tRPC, react-hook-form, Conform, and countless other tools have first-class Zod integration. Its API is intuitive, TypeScript inference is excellent, and the community is massive.

import { z } from "zod";

const UserSchema = z.object({
  name: z.string().min(2).max(50),
  email: z.string().email(),
  role: z.enum(["admin", "user", "viewer"]),
  tags: z.array(z.string()).optional(),
});
type User = z.infer<typeof UserSchema>; // Automatic type

Best for: Projects that use tRPC, react-hook-form, or any ecosystem tool with Zod integration. Most new projects — Zod is the safe default.

Yup — Still in Production Everywhere

Yup was the standard before Zod and still validates millions of forms in production (especially Formik projects). It's smaller than Zod and works well, but its TypeScript support lags behind and its development pace has slowed.

Best for: Existing Formik projects, codebases that already use Yup widely, teams that prefer stability over new features.

Valibot — Modular, Tiny, Fast

Valibot offers Zod-like features at a fraction of the bundle size. Every validation function is a named export — unused functions are tree-shaken away. For edge deployments or performance-sensitive apps, Valibot's 2KB footprint is compelling.

import * as v from "valibot";

const UserSchema = v.object({
  name: v.pipe(v.string(), v.minLength(2), v.maxLength(50)),
  email: v.pipe(v.string(), v.email()),
  role: v.picklist(["admin", "user", "viewer"]),
  tags: v.optional(v.array(v.string())),
});
type User = v.InferOutput<typeof UserSchema>;

Best for: Edge/serverless apps where bundle size matters, performance-sensitive projects, developers who prefer functional composition over method chaining.

Decision Matrix

ScenarioBest Library
New project, best ecosystemZod
Edge/serverless, bundle-consciousValibot
Existing Formik/Yup projectStay on Yup
tRPC stack (automatic integration)Zod

Bottom line: Zod is the default — the ecosystem support alone is worth the bundle size for most projects. Valibot for edge/serverless where every KB counts. Yup only if it's already in your codebase. See also: TypeScript Patterns and API Architecture Comparison.