
Zod vs Valibot: Bundle Size, Speed and a Clear 2026 Verdict
Zod vs Valibot tested on one schema: bundle size, Node.js parse speed, JSON Schema output and an import gotcha, with a verdict on which to use and where.
- What: Zod vs Valibot, tested side by side on Zod 4.6.7, Zod Mini and Valibot 1.5.0 with one schema.
- Why it matters: Validation code ships to browsers, edge functions and LLM tool calls, so bundle size and speed both count.
- What to do: Use Valibot for client and edge bundles; use Zod (compiled on hot paths) for Node.js servers.
- Key stat: Valibot’s own docs measure a login form at 1.37 kB versus 17.7 kB for Zod with esbuild.
Zod vs Valibot comes down to where your code runs. Valibot’s function-per-validator design tree-shakes to a much smaller bundle, which matters in browsers and edge functions. Zod 4 has a richer chainable API, a bigger ecosystem and an opt-in compiler that is much faster on valid input, which suits Node.js servers and hot API paths.
Zod and Valibot are TypeScript-first schema validation libraries: you declare a schema once, then use it to check unknown data at runtime and infer a static type from it. Zod uses chained methods on schema objects. Valibot uses small standalone functions composed with pipe(). Both implement the Standard Schema interface.
Zod vs Valibot is one of the most argued choices in TypeScript right now, and most comparisons repeat each library’s marketing numbers. Those numbers disagree. Valibot’s docs say a login form costs 17.7 kB with Zod and 1.37 kB with Valibot. Zod’s docs say a three-field object costs 13.1 kB with Zod and 4.0 kB with Zod Mini. Neither tells you what your schema costs, or what happens on the server.
So we ran our own test. We bundled the same five-field User schema with esbuild and measured parse throughput in Node.js. Every command and raw number is below, so you can repeat it. We also hit a bundling gotcha that none of the top comparisons mention: how you import Zod can more than triple its bundle.
This guide is for teams validating API input, form data, or LLM structured output in Node.js, Next.js or edge runtimes. It ends with a clear verdict.
What is the real difference between Zod vs Valibot?
The real difference is API shape, and API shape decides tree-shaking. Zod attaches methods to schema classes, so z.string().min(5) works. Valibot exposes one function per job, so the same rule is v.pipe(v.string(), v.minLength(5)).
Bundlers can drop unused top-level functions. They generally cannot drop unused methods on a class. Zod’s own docs say this directly: bundlers are generally not able to remove unused method implementations. That is why Zod 4 ships a second API, Zod Mini, at zod/mini.
Here is the schema we tested, in all three styles:
// Zod (classic API)
import * as z from "zod";
const User = z.object({
id: z.string().uuid(),
email: z.string().email(),
age: z.number().int().min(18),
role: z.enum(["admin", "user"]),
tags: z.array(z.string()).max(10),
});
// Zod Mini
import * as zm from "zod/mini";
const UserMini = zm.object({
id: zm.string().check(zm.uuid()),
email: zm.string().check(zm.email()),
age: zm.number().check(zm.int(), zm.minimum(18)),
role: zm.enum(["admin", "user"]),
tags: zm.array(zm.string()).check(zm.maxLength(10)),
});
// Valibot
import * as v from "valibot";
const UserV = v.object({
id: v.pipe(v.string(), v.uuid()),
email: v.pipe(v.string(), v.email()),
age: v.pipe(v.number(), v.integer(), v.minValue(18)),
role: v.picklist(["admin", "user"]),
tags: v.pipe(v.array(v.string()), v.maxLength(10)),
});
Both libraries infer the same TypeScript type from these schemas. Both return a result object from safeParse instead of throwing.
How big is the bundle for Zod vs Valibot?
Valibot was the smallest by a wide margin in our test. We used Zod 4.6.7, Valibot 1.5.0 and esbuild 0.28.2, with --bundle --minify --format=esm, then measured with gzip -9.
- Install:
npm i zod valibot esbuild - Bundle each file:
npx esbuild vali.js --bundle --minify --format=esm --outfile=out_vali.js - Measure:
wc -c < out_vali.jsandgzip -9 -c out_vali.js | wc -c
Raw output from our run:
zod (import * as z) raw=90023 gzip=26233
zod (import { z }) raw=454096 gzip=92456
zod/mini raw=19575 gzip=6825
valibot raw=5346 gzip=1904
Valibot came in at 1.9 KB gzipped, Zod Mini at 6.8 KB and regular Zod at 26.2 KB. Our Zod figure sits close to Zod’s own 24.1 KB measurement for a four-key object. It also matches a Valibot-team Cloudflare Workers test that measured 26.75 KiB for Zod 4.3.6 and 2.72 KiB for Valibot 1.3.1 gzipped.
The import gotcha: named import vs namespace import
Look at the second line of our output. Changing only the import line, from import * as z from "zod" to import { z } from "zod", grew the gzipped bundle from 26.2 KB to 92.5 KB.
We checked esbuild’s metafile to find out why. The named z export pulled in locale files, such as Hebrew and Russian error messages, plus JSON Schema conversion code. The namespace import let esbuild drop them. Zod’s docs use import * as z from "zod" in their examples, and now you know why it matters.
My recommendation: add a lint rule that bans import { z } in any code that ships to a browser or edge runtime.
Which is faster at runtime, Zod or Valibot?
On valid data, regular Zod and Valibot were close; compiled Zod was far ahead. On invalid data, Valibot was fastest. We ran 500,000 safeParse calls per library after a 50,000-call warm-up, three times each, on Node.js v22.23.5 in a 4-core Linux sandbox. These are medians.
library valid ops/s invalid ops/s
zod compiled 7,130,612 450,402
zod 1,447,850 465,842
valibot 1,258,244 743,417
zod/mini 811,814 293,827
Treat these as one machine’s numbers, not a universal ranking. They agree with Valibot’s own docs, which say it has similar runtime performance to Zod v4 but is slower than compiler-based libraries.
Why compiled Zod is so much faster
Zod 4.6 can compile a schema into flat JavaScript with z.compile(schema) or a global import "zod/compile". The generated code runs via new Function(), and Zod’s docs show speedups up to 7.8x on a 20-key object.
There are two catches. Invalid input falls back to the normal parser, so compilation barely speeds up failures; our invalid numbers confirm it. And the compiler adds about 7 KB gzipped to your bundle. Valibot deliberately avoids the Function constructor, which is why it has no equivalent.
Schema creation cost
We also timed creating 20,000 small two-field object schemas in a single run. Zod took 127 ms; Valibot took 7.5 ms. That only matters if you build schemas inside request handlers. Define schemas once at module scope and the cost disappears.
Does Zod vs Valibot matter for LLM structured outputs?
Yes, because LLM providers need JSON Schema, not a TypeScript object. Both libraries convert, but differently. Zod has z.toJSONSchema() built in. Valibot needs the separate @valibot/to-json-schema package (we used 1.8.0).
// Zod 4.6.7
z.toJSONSchema(z.object({ city: z.string(), days: z.number().int().max(7) }));
// → {"$schema":"https://json-schema.org/draft/2020-12/schema", ...
// "days":{"type":"integer","minimum":-9007199254740991,"maximum":7}, ...}
// Valibot 1.5.0 + @valibot/to-json-schema 1.8.0
toJsonSchema(v.object({ city: v.string(), days: v.pipe(v.number(), v.integer(), v.maxValue(7)) }));
// → {"type":"object", ... "days":{"type":"integer","maximum":7}, ...
// "$schema":"http://json-schema.org/draft-07/schema#"}
Notice two differences we saw in that output. Zod targets JSON Schema draft 2020-12 and adds a safe-integer minimum to .int(). Valibot targets draft-07 and emits only the bound you wrote. If a provider is strict about keywords or drafts, test the exact schema it receives.
In the Vercel AI SDK, Valibot schemas go through the valibotSchema helper from @ai-sdk/valibot. For the wider pattern of validating model output and retrying, see our guide to fixing broken JSON from LLM structured outputs in Node.js.
When should you choose Valibot over Zod?
Choose Valibot when the validator ships to a user’s device or an edge runtime. Every kilobyte there is parsed on a cold start or a slow phone.
- Client-side forms in React, Angular or Next.js client components.
- Edge functions on Cloudflare Workers, Vercel Edge or Deno Deploy, where the Valibot team argues cold starts are closer to the request path.
- Libraries you publish, so you don’t add 26 KB to every consumer.
Bundle size is only one part of front-end speed. Our JavaScript performance checklist covers the rest of the budget.
When should you choose Zod over Valibot?
Choose Zod for long-running Node.js servers, hot API validation paths and teams that value a discoverable API. Zod’s docs make the backend case themselves: they cite a benchmark where a 128 KB bundle added only 5 ms to a Lambda cold start over a 1 KB bundle.
- Express, Fastify or NestJS APIs, where compiled Zod gave us over 5x the valid-input throughput.
- Teams new to schema validation, because chained methods autocomplete well. Even Zod’s author says Zod Mini is more verbose and less discoverable.
- Codebases already on Zod, where a rewrite costs more than the kilobytes it saves.
Whichever you pick, both are dependencies in your supply chain. Pin versions and review updates as described in our npm supply chain defense guide. Check current releases on npm for zod and valibot before you upgrade.
Can Zod and Valibot work together through Standard Schema?
Yes. Standard Schema is a shared TypeScript interface created by the authors of Zod, Valibot and ArkType. Each schema exposes a ~standard property with a validate function, so a tool can accept either library without an adapter.
This is the practical escape hatch. Write internal helpers against StandardSchemaV1 instead of a specific library. Then you can use Valibot in the browser and Zod on the server without duplicating your plumbing.
| Factor | Zod | Zod Mini | Valibot |
|---|---|---|---|
| Bundle, our 5-field schema (gzip) | 26.2 KB | 6.8 KB | 1.9 KB |
| Login form, per Valibot docs (esbuild) | 17.7 kB | 6.88 kB | 1.37 kB |
| Valid parses/s, our Node 22 run | 1.45M (7.13M compiled) | 0.81M | 1.26M |
| Invalid parses/s, our Node 22 run | 0.47M | 0.29M | 0.74M |
| API style | Chained methods | Functions + .check() |
Functions + pipe() |
| JSON Schema output | Built in (draft 2020-12) | Built in | Separate package (draft-07) |
Uses new Function |
Only if compiled; jitless option | Only if compiled | Never |
| Standard Schema | Yes | Yes | Yes |
The NexGismo verdict: use Valibot for anything that ships to a browser or edge runtime, and Zod for Node.js servers, with z.compile() on hot paths. Zod Mini sits awkwardly in between: in our test it was 3.6x larger than Valibot and slower than regular Zod. If you stay on Zod, use the namespace import; that one line was worth 66 KB gzipped in our build.
- In an esbuild test of one five-field schema, Valibot 1.5.0 bundled to 1.9 KB gzipped and Zod 4.6.7 to 26.2 KB.
- Importing Zod as
import { z } from "zod"produced a 92.5 KB gzipped bundle;import * as zproduced 26.2 KB. - Regular Zod 4 and Valibot 1.5 parse valid data at similar speeds on Node.js 22, about 1.3 to 1.5 million parses per second.
- Compiled Zod reached about 7.1 million valid parses per second but gave no gain on invalid input.
- Zod converts to JSON Schema draft 2020-12 natively; Valibot needs @valibot/to-json-schema and outputs draft-07.
- Both libraries implement Standard Schema, so tools can accept either without adapters.
Frequently Asked Questions
Is Valibot better than Zod?
Neither is better everywhere. Valibot produces far smaller browser and edge bundles: our esbuild test gave 1.9 KB gzipped against 26.2 KB for regular Zod. Zod has the larger ecosystem, a chainable API and an opt-in compiler that was over 5x faster on valid input. Pick by where the code runs.
Is Valibot faster than Zod?
On valid input in our Node.js 22 test, regular Zod 4.6.7 and Valibot 1.5.0 were close, about 1.45 million versus 1.26 million parses per second. Valibot was faster on invalid input. Compiled Zod reached about 7.1 million valid parses per second, which Valibot cannot match because it avoids the Function constructor.
What is the difference between Zod and Zod Mini?
Zod Mini is a tree-shakable, functional variant of Zod 4 imported from zod/mini. It replaces methods such as .min() with functions passed to .check(), and it does not load the English locale by default. It is smaller than regular Zod but still larger than Valibot in our test: 6.8 KB versus 1.9 KB gzipped.
Can I use Valibot with the Vercel AI SDK?
Yes. The AI SDK provides a valibotSchema helper in the @ai-sdk/valibot package. It converts a Valibot schema into a JSON schema object the SDK can use for structured data generation and for tool definitions. Zod schemas can be passed to the SDK directly without a separate adapter package.
Should I migrate from Zod to Valibot?
Migrate only if bundle size or cold start cost is a measured problem, such as a browser form bundle or an edge function. For long-running Node.js servers the difference is small; Zod’s own docs say bundle size at Zod’s scale rarely matters on the backend. Valibot publishes a Zod migration guide with a codemod.
Which should you pick?
The Zod vs Valibot debate gets easier once you measure your own schema instead of trusting each project’s headline number. In our test, Valibot won on bundle size by more than 13x, and compiled Zod won on server throughput by more than 5x. Both are mature, typed and Standard Schema compatible, so neither choice traps you.
Start with where the code runs. Browser or edge: Valibot. Long-running Node.js server: Zod. Then run the three-step esbuild check above on your real schemas before you commit. If you try it, I’d like to hear how your numbers compare.
Sources
- Zod — Zod Mini documentation
- Zod — AOT compilation documentation
- Valibot — Comparison with Zod and others
- Valibot blog — How Dependency Size Impacts Cold Starts in Edge JavaScript Runtimes
- Standard Schema — specification repository on GitHub
- Vercel AI SDK — valibotSchema reference
- npm — zod package
- npm — valibot package