Programming |

Zod vs Valibot in 2026: Schema Validation Bundle Size and DX Compared

A practical 2026 comparison of Zod vs Valibot — bundle size, tree-shaking, inference quality, runtime cost, and the workloads where each validator wins.

By SouvenirList

You pull up your Next.js bundle analyzer and one line stands out: zod is 54 KB gzipped, shipped to the browser on every page because you imported it into a shared form component. Someone posts a Valibot benchmark in the team channel showing the same validation in under 2 KB, and suddenly the conversation is real. In 2026, the Zod vs Valibot decision is no longer theoretical — Valibot’s bundle-size advantage maps directly to Core Web Vitals, and Zod’s API advantages map directly to developer velocity.

This piece walks through the real Zod vs Valibot differences in 2026 — bundle size per validator, tree-shaking mechanics, type inference quality, runtime performance, and the five cases where each one clearly wins.


TL;DR

  • Zod is a mature, object-oriented schema validator with a fluent API: z.object({...}), method chaining.
  • Valibot is a tree-shakeable, functional validator: individual functions (object, string, minLength) composed with pipe().
  • Bundle size on a typical form schema: Valibot 1–3 KB, Zod 12–15 KB, gzipped — roughly a 10x advantage for Valibot.
  • Tree-shaking: Valibot ships only what you import; Zod ships most of the library regardless.
  • Type inference quality: both excellent; Zod has a slight edge on complex transforms, Valibot a slight edge on narrow types.
  • Ecosystem depth: Zod has broader integrations (React Hook Form, tRPC, tRPC-OpenAPI, AI SDK schemas). Valibot is catching up fast.
  • Use Valibot when bundle size matters — edge, mobile, public-facing forms. Use Zod when velocity matters — server code, tooling, integrations.

Deep Dive: Where Each Validator Wins

Bundle Size and Tree-Shaking

Zod’s API is object-oriented:

import { z } from "zod";
const schema = z.object({
  email: z.string().email(),
  age: z.number().min(18),
});

Importing z brings in most of Zod’s methods because they’re attached to the schema classes. Bundlers can’t tree-shake method chains the way they can function imports.

Valibot is function-first:

import { object, string, pipe, email, number, minValue } from "valibot";
const schema = object({
  email: pipe(string(), email()),
  age: pipe(number(), minValue(18)),
});

Each function is its own module. Your bundle contains exactly the validators you imported, and nothing else. On a simple form schema with 5 fields, the size difference is typically:

  • Zod: 12–15 KB gzipped
  • Valibot: 1–3 KB gzipped

On a complex schema with dozens of rules, Zod grows slowly (the machinery is already included) and Valibot grows linearly with imports. Past ~30 rules, the gap narrows — but it never inverts.

Runtime Performance

Both validate in microseconds for typical form payloads. Under contrived benchmarks with deep schemas and many fields, Valibot is marginally faster because the function-based approach skips some allocation overhead. In real applications, validation is never the hot path — don’t pick on runtime perf alone.

Type Inference Quality

Both produce clean inferred types:

// Zod
type User = z.infer<typeof schema>;

// Valibot
type User = InferOutput<typeof schema>;

Inferred types match each other closely. Zod’s z.infer has a few more utility types layered on top (z.input, z.output) that occasionally matter for advanced transforms. Valibot’s InferInput / InferOutput are equivalent in practice.

Where they can diverge: complex transforms and refinements. Zod’s .transform() and .refine() chain cleanly; Valibot’s equivalents (transform(), check()) require more explicit composition via pipe(). For simple cases, parity. For heavy transform pipelines, Zod is slightly smoother.

Ecosystem and Integrations

  • Zod is the default for React Hook Form (@hookform/resolvers/zod), tRPC schemas, OpenAPI generation (zod-to-openapi), and AI SDK structured output. Our Claude structured output with Zod piece walks through that specific use case.
  • Valibot ships resolvers for React Hook Form and has growing support in form libraries and server frameworks. For AI SDK integrations, Zod still dominates in 2026.

If your stack is deeply integrated with tools that expect Zod, switching carries migration cost beyond the validator itself. Budget a few days for peripheral updates on a real codebase.


Pros & Cons

ZodValibot
Bundle size (simple schema)12–15 KB1–3 KB
Tree-shakingLimitedFull
Type inference qualityExcellentExcellent
Complex transformsSmoothRequires explicit pipe
Ecosystem integrationsBroadGrowing
Learning curveLow (OO, fluent)Low (functional)
Maturity4+ years, widely adoptedYounger, growing fast
Best-fit workloadsServer, tooling, AIEdge, mobile, public forms

The honest trade-off: Valibot buys you bundle size and tree-shakeability at the cost of ecosystem depth and API familiarity. Zod buys you integration breadth and fluent API comfort at the cost of bundle weight.


Who Should Use This

Choose Valibot when:

  • You’re building for the edge — Cloudflare Workers, Vercel Edge, Deno Deploy — where every KB matters. See our Cloudflare Workers vs AWS Lambda piece for the broader edge constraints.
  • You’re shipping to mobile browsers on slow connections where Core Web Vitals drive real conversion metrics.
  • You’re building a public-facing form-heavy site where validation code is loaded on initial page view.
  • Your team is comfortable with functional composition via pipes.

Choose Zod when:

  • You’re validating on the server — bundle size doesn’t matter, integration breadth does.
  • You’re using tRPC, React Hook Form, AI SDK structured output where Zod is the default.
  • Your team wants the fluent chaining API for readability and quick ramp-up.
  • You have complex transform pipelines where Zod’s .transform() chains cleanly.

The hybrid pattern — Valibot on the client, Zod on the server, shared types in a common package — works for teams that care about both concerns. It costs you duplicate schema definitions, so weigh carefully.


FAQ

Can I migrate from Zod to Valibot incrementally?

Yes. Both coexist peacefully. Migrate one schema at a time, starting with the ones in the hottest bundle paths (public forms, landing pages). The type output is compatible at the consumer level, so downstream code often doesn’t need changes.

Does Valibot support async validation?

Yes — parseAsync and safeParseAsync equivalents exist. The API shape mirrors Zod’s async validation patterns.

What about Yup or Joi — are they still relevant?

Yup remains in use but is losing ground to Zod for TypeScript-first projects because Yup’s inference is weaker. Joi is largely a Node-backend choice with fewer TypeScript-focused advantages. For new TypeScript projects, Zod vs Valibot is the live debate; Yup and Joi are legacy unless you have existing tooling.

Can I use Valibot with tRPC?

As of 2026, tRPC supports Valibot via community adapters. First-party Zod integration is still deeper. If tRPC is a hard dependency, staying on Zod avoids integration tax.

Does either have a JSON Schema converter?

Both have community schema-to-json-schema packages. Zod’s converters are more mature and better-maintained; Valibot’s are catching up. For OpenAPI generation specifically, Zod still wins in 2026.


Bottom Line

Zod vs Valibot in 2026 is not “better vs worse” — it’s “where does this validator ship?” Valibot wins on the client and at the edge because bundle size is the ballgame. Zod wins on the server and in toolchains because integration depth is the ballgame. For most teams, a hybrid — Valibot for user-facing forms, Zod for API and AI contracts — is the pragmatic answer. Measure your bundle before committing.

Product recommendations are based on independent research and testing. We may earn a commission through affiliate links at no extra cost to you.

Tags: Zod Valibot schema validation TypeScript bundle size

Related Articles