Zod vs Valibot
Both are TypeScript-first schema validators. The difference is architecture: Zod is battle-tested and monolithic; Valibot is tree-shakeable and ultra-lightweight.
At a Glance
| Feature | Zod | Valibot |
|---|---|---|
| TypeScript-first | Yes | Yes |
| Type inference | z.infer<typeof schema> | v.InferOutput<typeof schema> |
| Bundle size (min) | ~13 KB (monolithic) | < 1 KB per validator (tree-shakeable) |
| Architecture | Monolithic — import loads all | Modular — import only what you use |
| API style | Method chaining (.string().min(2)) | pipe() composition (pipe(string(), minLength(2))) |
| Validation speed | Fast | Generally faster (2-5x on benchmarks) |
| Ecosystem maturity | Very high — de facto standard | Growing — younger community |
| tRPC integration | First-class | Adapter available |
| React Hook Form | Official resolver | Valibot resolver available |
| Async validation | Yes (parseAsync) | Yes (parseAsync) |
| Error formatting | ZodError with flatten() | ValiError with structured issues |
| Best for | Most TypeScript projects | Edge/browser — bundle size critical |
The Core Difference: Bundle Size & Architecture
Zod bundles everything together. When you write import { z } from "zod", the whole ~13 KB library loads — even validators you never use. For server-side Node.js, this is irrelevant. For edge functions (Cloudflare Workers, Vercel Edge) or browser bundles, every kilobyte counts.
Valibot is built from the ground up as individual functions that bundlers can tree-shake. If your schema only uses string, email, and object, only those few hundred bytes land in your bundle.
Same Schema, Two Libraries
User registration schema
Zod
import { z } from "zod";
const RegisterSchema = z.object({
username: z.string()
.min(3)
.max(20)
.regex(/^[a-z0-9_]+$/),
email: z.string().email(),
password: z.string().min(8),
age: z.number().int().min(13).optional(),
});
type RegisterInput = z.infer<typeof RegisterSchema>;
// Parse (throws on error):
const data = RegisterSchema.parse(input);
// Safe parse (no throw):
const result = RegisterSchema.safeParse(input);
if (result.success) {
console.log(result.data.username);
}Valibot
import * as v from "valibot";
const RegisterSchema = v.object({
username: v.pipe(
v.string(),
v.minLength(3),
v.maxLength(20),
v.regex(/^[a-z0-9_]+$/)
),
email: v.pipe(v.string(), v.email()),
password: v.pipe(v.string(), v.minLength(8)),
age: v.optional(v.pipe(v.number(), v.integer(), v.minValue(13))),
});
type RegisterInput = v.InferOutput<typeof RegisterSchema>;
// Parse (throws on error):
const data = v.parse(RegisterSchema, input);
// Safe parse (no throw):
const result = v.safeParse(RegisterSchema, input);
if (result.success) {
console.log(result.output.username);
}Discriminated unions
Zod
const EventSchema = z.discriminatedUnion("type", [
z.object({
type: z.literal("click"),
x: z.number(),
y: z.number(),
}),
z.object({
type: z.literal("keydown"),
key: z.string(),
}),
]);
type Event = z.infer<typeof EventSchema>;Valibot
const EventSchema = v.variant("type", [
v.object({
type: v.literal("click"),
x: v.number(),
y: v.number(),
}),
v.object({
type: v.literal("keydown"),
key: v.string(),
}),
]);
type Event = v.InferOutput<typeof EventSchema>;Choose Zod when:
- ✓ You want the largest ecosystem and most community resources
- ✓ Using tRPC (Zod is the native validator)
- ✓ Bundle size is not a primary constraint
- ✓ Your team already knows Zod
- ✓ You rely on third-party integrations (most target Zod first)
- ✓ Building a server-side Node.js or Next.js app
Choose Valibot when:
- ✓ Targeting edge runtimes (Cloudflare Workers, Vercel Edge)
- ✓ Building browser-side validation with a tight bundle budget
- ✓ Maximum validation performance is critical
- ✓ Starting a new project and want the modern modular approach
- ✓ Your framework/library already has Valibot adapters
Frequently Asked Questions
What is the main difference between Zod and Valibot?
The key difference is architecture. Zod is monolithic (~13 KB min) — any import loads the full library. Valibot is modular and tree-shakeable, so bundlers only include the validators you actually use. A minimal Valibot schema can be under 1 KB. Both are TypeScript-first with automatic type inference.
Is Valibot faster than Zod?
Benchmarks show Valibot is generally faster (2-5x on simple schemas). In practice, both are well under 1ms per validation for typical schemas, so the difference is usually imperceptible in application code.
Does Valibot have the same API as Zod?
The APIs are similar but not identical. Valibot uses pipe() to compose validators instead of method chaining. Zod's z.string().min(2).email() becomes v.pipe(v.string(), v.minLength(2), v.email()) in Valibot. Type inference uses v.InferOutput<typeof schema> instead of z.infer<typeof schema>.
Is Valibot production-ready?
Valibot is production-ready and actively maintained, but younger than Zod. Zod has first-class integrations in tRPC, React Hook Form, Astro, and many other libraries. Valibot has adapters for most but you may hit edges not yet covered by the community.
Should I migrate from Zod to Valibot?
Only migrate if bundle size is a critical constraint — edge functions or browser code where every KB matters. If your app is server-rendered or bundle size is not a bottleneck, the migration cost is unlikely to be worth it.
Which should I use for a new TypeScript project?
Use Zod for most projects — the ecosystem, community, and integrations are unmatched. Use Valibot if you are building for edge or browser with strict bundle size constraints from the start.
How much smaller is Valibot than Zod?
Valibot is typically 10-30x smaller than Zod in bundle size. Zod bundles around 12-15 KB minified+gzipped; Valibot can be under 1 KB for simple schemas because it uses tree-shaking-friendly functional design. Bundle size matters most for browser-side validation.
Is Valibot production-ready?
Valibot reached v1.0 in 2024 and is production-ready. It is gaining adoption in the Hono, SvelteKit, and edge-computing communities where bundle size is critical. Zod has broader ecosystem support and more third-party integrations.
Working with Zod? The cheatsheet has everything.
All schema types, refinements, transforms, and error handling patterns in one page.
Zod Cheatsheet →From the blog
View all →
Jun 8, 2026
JavaScript Object to JSON: Serialization Patterns and Common Pitfalls

Jun 8, 2026
TypeScript to JavaScript: When and How to Strip Types

Jun 4, 2026
JavaScript Object to JSON: Serialization Patterns and Common Pitfalls

Jun 4, 2026
TypeScript to JavaScript: When and How to Strip Types

Jun 1, 2026
JSON to TypeScript: Auto-Generate Interfaces from API Responses