Zod vs Valibot vs ArkType: Which Runtime Validator Should You Use for API Input in TypeScript?
Short answer: Use Zod if you want the default with the largest ecosystem and you run on a server where bundle size doesn't matter. Use Valibot if the validator ships to the browser and every kilobyte counts. Use ArkType
Short answer: Use Zod if you want the default with the largest ecosystem and you run on a server where bundle size doesn't matter. Use Valibot if the validator ships to the browser and every kilobyte counts. Use ArkType if you like writing schemas that look like TypeScript types and care about raw validation speed. All three now implement the Standard Schema interface, so the choice is much less of a lock-in than it was a couple of years ago.
(As of late 2026. Library versions move quickly; the trade-offs below are structural and have held across recent major releases, but check each changelog before migrating.)
Why do you need a runtime validator at all?
TypeScript types vanish at compile time. The classic bug looks like this:
app.post("/users", (req, res) => {
const body = req.body as { email: string; age: number }; // a lie
db.insert(body.email.toLowerCase()); // TypeError: Cannot read properties of undefined (reading 'toLowerCase')
});
The cast tells the compiler to trust data that arrived over a network. A validator turns unknown into a typed value or a structured error, and gives you one schema that is both the runtime check and the static type.
Takeaway: a as cast on request data is a bug waiting for the first malformed client.
How do the three differ in writing a schema?
The same "create user" payload in each library:
// Zod
import { z } from "zod";
const CreateUser = z.object({
email: z.email(),
age: z.number().int().min(18),
});
type CreateUser = z.infer<typeof CreateUser>;
// Valibot
import * as v from "valibot";
const CreateUserV = v.object({
email: v.pipe(v.string(), v.email()),
age: v.pipe(v.number(), v.integer(), v.minValue(18)),
});
type CreateUserV = v.InferOutput<typeof CreateUserV>;
// ArkType
import { type } from "arktype";
const CreateUserA = type({
email: "string.email",
age: "number.integer >= 18",
});
type CreateUserA = typeof CreateUserA.infer;
Zod uses a method-chaining API that autocompletes well and reads naturally. Valibot uses standalone functions composed with pipe, which is more verbose but lets bundlers drop everything you don't import. ArkType uses string expressions parsed at definition time, which is compact but means you are learning a small DSL, and typos inside strings rely on the library's type-level parsing to be caught.
Takeaway: Zod optimizes for discoverability, Valibot for tree-shaking, ArkType for density.
Which one should you pick? A decision table
| Concern | Zod | Valibot | ArkType |
|---|---|---|---|
| Ecosystem (form libs, tRPC-style tools, ORMs, OpenAPI generators) | Broadest | Growing | Smaller |
| Browser bundle impact | Larger than Valibot, improved in recent major versions | Designed around modular imports | Larger runtime, optimized for speed over size |
| Schema style | Method chaining | Functions + pipe
|
TypeScript-like strings |
| JSON Schema output | Built in for recent versions | Separate companion package | Built in for recent versions |
| Learning curve | Lowest | Low | Medium (the DSL) |
| Main drawback | Heaviest of the three for client bundles | Verbose; fewer integrations | DSL quirks; smaller community to search for answers |
I won't quote benchmark numbers here: results depend heavily on schema shape, runtime, and version, and a figure copied from someone else's repo is exactly the kind of claim that goes stale. If validation is on a hot path, benchmark your own schemas with your own payloads.
If you want the safe default for a typical Node API, Zod is the one that works with the most surrounding tools without glue code.
Takeaway: pick by where the code runs (server vs browser) and what you integrate with, not by a leaderboard.
What does an error look like when validation fails?
This is where I'd spend ten minutes before committing, because the error shape is what your API clients and your logs will actually see. Zod and Valibot both return a list of issues with a path and a message; ArkType returns an errors object with a readable summary.
// Zod
const r = CreateUser.safeParse({ email: "nope", age: 12 });
if (!r.success) console.log(r.error.issues.map(i => `${i.path.join(".")}: ${i.message}`));
// Valibot
const rv = v.safeParse(CreateUserV, { email: "nope", age: 12 });
if (!rv.success) console.log(rv.issues.map(i => i.message));
// ArkType
const out = CreateUserA({ email: "nope", age: 12 });
if (out instanceof type.errors) console.log(out.summary);
Default messages are written for developers, not end users. Whichever library you choose, map issues into your own stable API error format ({ field, code }) rather than leaking library wording to clients, or a minor upgrade will silently change your API's responses.
Takeaway: never return a validator's raw message text as part of a public API contract.
Can you stay library-agnostic? Standard Schema
Zod, Valibot, and ArkType all expose a common ~standard interface (the Standard Schema spec), and many libraries accept any compliant schema. That means you can write framework glue once:
import type { StandardSchemaV1 } from "@standard-schema/spec";
export class HttpError extends Error {
constructor(public status: number, message: string) {
super(message);
}
}
export async function parseBody<S extends StandardSchemaV1>(
schema: S,
input: unknown,
): Promise<StandardSchemaV1.InferOutput<S>> {
const result = await schema["~standard"].validate(input);
if (result.issues) {
throw new HttpError(400, result.issues.map(i => i.message).join("; "));
}
return result.value;
}
Now parseBody(CreateUser, req.body) works with any of the three. The limit: Standard Schema covers validation and type inference, not library-specific features like Zod's transforms API details or ArkType's morphs, so heavy use of those still ties you in.
Takeaway: route every request through one parseBody-style wrapper and a migration becomes a schema rewrite, not a codebase rewrite.
FAQ
Is Valibot smaller than Zod?
Generally yes for client bundles, because Valibot's functions are individually importable and tree-shakable; the gap has narrowed since Zod's recent major version, so measure with your bundler if it matters.
Should I use safeParse or parse for API input?
Use the safe variant (safeParse in Zod and Valibot) so a bad request becomes a 400 you control instead of an uncaught exception that becomes a 500.
Can I migrate from Zod to Valibot or ArkType gradually?
Yes, if you wrap validation behind Standard Schema first: new routes can use the new library while old ones keep their Zod schemas.
Bottom line
Choose Zod if you want the least friction and the widest tool support. Choose Valibot when the schema runs in a browser bundle and size is measurable. Choose ArkType if you enjoy the TypeScript-style syntax and are comfortable with a smaller community. Whichever you pick, wrap it in one validation function and keep your public error format independent of the library.
Related reading
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.