Whenever runtime validation comes up in a TypeScript project, one question usually follows:
Which validation library should I choose?
Should I use Zod, Valibot, ArkType, or typia?
Or would a simple, handwritten type guard do the job?
Recently, I started thinking about whether these tools are actually solving the same problem.
Imagine all I need is a quick check that tells TypeScript whether an unknown value is a valid user:
if (isUser(input)) {
input.name;
}Do I really need an entire schema-validation system for that?
Probably not.
But what if I also need structured validation errors, data transformations, parsing, schema metadata, and integrations with other frameworks? A simple function returning true or false might not be sufficient.
That made me reconsider how I approach validation libraries.
Rather than declaring one library the winner, I decided to implement the same User validation rules using seven different approaches:
A handwritten TypeScript type guard
is-kitRuntypesValibotZodArkTypetypia
I compiled the implementations, tested them against the same input fixtures, measured their standalone browser bundle sizes, and ran runtime benchmarks.
The most challenging part wasn't getting all seven implementations to compile.
It was ensuring that all seven were actually enforcing the same rules.
Even a seemingly simple requirement such as limiting a string to 100 characters can mean different things depending on how a validator handles Unicode.
Let's examine what each approach offers and where the differences become important.
π§ͺ Defining the User We Want to Validate
Before comparing implementations, we need a common data structure and a clearly defined contract.
Here is our shared TypeScript type:
type User = {
id: string;
name: string;
age: number;
role: "admin" | "user";
tags: string[];
profile: {
bio: string;
active: boolean;
};
};Every implementation must enforce these runtime requirements:
idmust be a string.namemust contain between 1 and 100 UTF-16 code units.agemust be an integer between 18 and 120.rolemust be exactly"admin"or"user".tagsmust be an array containing strings.profile.biomust be a string.profile.activemust be a boolean.Unknown properties must be rejected at both the root and nested
profilelevels.Values must not be automatically converted into different types.
For the main comparison, we'll focus on ordinary data produced by parsing JSON.
This scope matters. JavaScript objects can contain inherited properties, sparse arrays, symbols, getters, and non-enumerable properties. Those cases can produce different results even when validators appear to implement identical rules.
We'll investigate those edge cases later.
1. βοΈ Handwritten Type Guards: Sometimes Simpler Is Better
Let's begin with the most straightforward approach: writing our own JavaScript checks and using a TypeScript predicate to narrow the type.
No external validation library is required.
const isRecord = (
value: unknown,
): value is Record<string, unknown> =>
typeof value === "object" &&
value !== null &&
!Array.isArray(value);
const hasExactKeys = (
value: Record<string, unknown>,
keys: readonly string[],
): boolean =>
Object.keys(value).length === keys.length &&
keys.every((key) => Object.hasOwn(value, key));
export const isUser = (value: unknown): value is User => {
if (
!isRecord(value) ||
!hasExactKeys(value, [
"id",
"name",
"age",
"role",
"tags",
"profile",
])
) {
return false;
}
if (
!isRecord(value.profile) ||
!hasExactKeys(value.profile, ["bio", "active"])
) {
return false;
}
return (
typeof value.id === "string" &&
typeof value.name === "string" &&
value.name.length >= 1 &&
value.name.length <= 100 &&
typeof value.age === "number" &&
Number.isInteger(value.age) &&
value.age >= 18 &&
value.age <= 120 &&
(value.role === "admin" || value.role === "user") &&
Array.isArray(value.tags) &&
value.tags.every((tag) => typeof tag === "string") &&
typeof value.profile.bio === "string" &&
typeof value.profile.active === "boolean"
);
};We can then use the guard like this:
declare const input: unknown;
if (isUser(input)) {
input.name.toUpperCase();
}Once isUser(input) returns true, TypeScript allows us to work with input as a User.
For a small validation boundary, this approach has a major advantage: there is no additional abstraction to learn.
Everything is handled with familiar JavaScript checks and TypeScript's type-predicate system.
The downside appears as an application grows.
You might gradually accumulate functions such as:
isUser;
isProfile;
isRole;
isNonEmptyString;
isAdultAge;
isStringArray;
isApiResponse;
isConfig;
isFeatureFlag;At that point, you're no longer maintaining one or two guards. You're maintaining your own small validation toolkit.
That isn't necessarily bad, but it introduces a maintenance cost.
And that leads us to the next approach.
2. π§ is-kit: Composable Guards Without a Schema-First Workflow
is-kit takes a different approach. Instead of requiring a schema definition for every validation task, it provides small, reusable guards that can be combined.
Here's how we can express our validation rules:
import {
and,
arrayOf,
isBoolean,
isNumber,
isString,
oneOfValues,
predicateToRefine,
safeParse,
struct,
} from "is-kit";
export const isName = and(
isString,
predicateToRefine<string>(
(value) => value.length >= 1 && value.length <= 100,
),
);
export const isAge = and(
isNumber,
predicateToRefine<number>(
(value) =>
Number.isInteger(value) &&
value >= 18 &&
value <= 120,
),
);
export const isProfile = struct(
{
bio: isString,
active: isBoolean,
},
{ exact: true },
);
export const isUser = struct(
{
id: isString,
name: isName,
age: isAge,
role: oneOfValues("admin", "user"),
tags: arrayOf(isString),
profile: isProfile,
},
{ exact: true },
);
export const parseUser = (input: unknown) =>
safeParse(isUser, input);The individual components remain ordinary guards that can be reused independently.
For example:
const names = values.filter(isName);
if (isAge(value)) {
// value is number
}This is particularly useful when a codebase already relies on predicates for narrowing values.
However, there's a boundary to what this approach provides.
safeParse() wraps a guard in a simple success-or-failure result. It doesn't automatically provide the complete capabilities of a schema-validation ecosystem.
For example, it doesn't turn is-kit into:
A detailed, field-level validation issue system.
A data-transformation pipeline.
A schema metadata framework.
An OpenAPI tooling ecosystem.
A form integration layer.
If those features are central to an application, choosing a dedicated schema library may be more appropriate than trying to extend a guard toolkit into something it wasn't designed to be.
There's also a TypeScript detail worth noting. The struct() and arrayOf() helpers infer readonly structures. Consequently, an inferred readonly string[] isn't assignable to a mutable string[], even when the runtime data has the expected shape.
That's a genuine type-level distinction. It should be acknowledged in type tests rather than hidden with a cast.
3. π Runtypes: A Runtime Validator With Multiple Ways to Use It
Runtypes introduces a different model.
Instead of representing validation solely as a boolean predicate, it gives us a runtime validator object that supports several operations.
import {
Array as RtArray,
Boolean as RtBoolean,
Literal,
Number as RtNumber,
Object as RtObject,
String as RtString,
Union,
} from "runtypes";
const Name = RtString.withConstraint(
(value) =>
(value.length >= 1 && value.length <= 100) ||
"name length must be 1..100",
);
const Age = RtNumber.withConstraint(
(value) =>
(Number.isInteger(value) &&
value >= 18 &&
value <= 120) ||
"age must be an integer in 18..120",
);
export const UserSchema = RtObject({
id: RtString,
name: Name,
age: Age,
role: Union(Literal("admin"), Literal("user")),
tags: RtArray(RtString),
profile: RtObject({
bio: RtString,
active: RtBoolean,
}).exact(),
}).exact();
export const isUser = (input: unknown) =>
UserSchema.guard(input);
export const checkUser = (input: unknown) =>
UserSchema.check(input);
export const parseUser = (input: unknown) =>
UserSchema.parse(input);
export const inspectUser = (input: unknown) =>
UserSchema.inspect(input);The important difference is that a single runtime object can support multiple use cases.
A simple predicate answers:
Does this value satisfy the requirements for a
User?
A Runtypes validator can also:
Narrow types through
guard.Check values through
check.Parse values through
parse.Provide structured information about failures.
One detail deserves special attention: check() and parse() shouldn't automatically be treated as interchangeable methods.
Runtypes supports parsing behavior, and object handling can differ depending on whether we're validating or parsing.
This is additional runtime functionality that a basic handwritten predicate doesn't provide.
The trade-off is that we're now working with a richer abstraction, rather than simply composing boolean checks.
4. π€ Valibot: Schema Validation Through a Modular API
Valibot brings us further into the schema-validation world.
Here's the same User contract expressed using its API:
import * as v from "valibot";
export const UserSchema = v.strictObject({
id: v.string(),
name: v.pipe(
v.string(),
v.minLength(1),
v.maxLength(100),
),
age: v.pipe(
v.number(),
v.integer(),
v.minValue(18),
v.maxValue(120),
),
role: v.picklist(["admin", "user"]),
tags: v.array(v.string()),
profile: v.strictObject({
bio: v.string(),
active: v.boolean(),
}),
});
export const isUser = (input: unknown) =>
v.is(UserSchema, input);
export const parseUser = (input: unknown) =>
v.safeParse(UserSchema, input);This provides several capabilities:
Runtime schema validation.
Type inference.
Structured validation issues.
Parsing operations.
Composable transformation pipelines.
One of Valibot's defining characteristics is its modular, function-oriented API.
Rather than placing every operation on a large schema object, it encourages composing smaller functions.
That design also supports tree shaking, allowing bundlers to remove unused functionality from the resulting application bundle.
Valibot isn't limited to schema parsing, either. Its v.is() function can act as a type guard.
That means schema validation and ordinary TypeScript narrowing can coexist.
There is one important distinction: v.is() is the guard operation. It doesn't return detailed validation issues or apply parsing transformations. For those capabilities, we use the appropriate parsing API.
5. π Zod: The Value of a Larger Ecosystem
Zod is another widely used schema-validation option.
Here's an implementation of our contract:
import * as z from "zod";
export const UserSchema = z.strictObject({
id: z.string(),
name: z
.string()
.refine(
(value) => value.length >= 1 && value.length <= 100,
"name must contain 1..100 UTF-16 code units",
),
age: z.int().min(18).max(120),
role: z.enum(["admin", "user"]),
tags: z.array(z.string()),
profile: z.strictObject({
bio: z.string(),
active: z.boolean(),
}),
});
export type User = z.output<typeof UserSchema>;
export const parseUser = (input: unknown) =>
UserSchema.safeParse(input);
// This schema has no transforms, so its output type is safe for the input too.
export const isUser = (
input: unknown,
): input is User => parseUser(input).success;Zod doesn't provide a built-in is() method in the same way Valibot does. However, we can use a successful safeParse() result to narrow the input in this example because the schema doesn't transform the data.
With a transforming schema, the distinction between input and output types matters. The validated result in safeParse().data is the value whose output type should be trusted.
The ability to validate a User isn't what makes Zod particularly interesting. Every approach in this comparison can implement that basic requirement.
Its broader ecosystem is often the more important consideration.
Depending on the surrounding tools, that ecosystem can include:
Form integrations.
API tooling.
Schema conversion.
Metadata.
Codecs.
OpenAPI-related tooling.
Framework integrations.
If your schemas are becoming part of the infrastructure of an application, those integrations can be more valuable than the validation function itself.
A subtle issue with string length
You might wonder why I didn't simply write:
z.string().min(1).max(100);Our requirement is specifically 1β100 UTF-16 code units.
Zod's built-in string-length constraints count Unicode code points, which isn't the same measurement as JavaScript's string.length.
To preserve our exact contract, the example uses .refine() and explicitly checks value.length.
We'll see why that matters when we examine the emoji test case.
What about bundle size?
It's easy to make a broad claim such as:
Valibot is small, while Zod is large.
That comparison needs more context.
Zod also offers Zod Mini, which uses a more functional, tree-shakable API. The bundle measurements later in this article use regular Zod, not Zod Mini.
Therefore, those numbers shouldn't be interpreted as a comparison between Valibot and the smallest possible Zod implementation.
Zod can also compile optimized validation logic at runtime through z.compile() and new Function. That capability wasn't enabled in this comparison.
It's useful to distinguish two approaches that can otherwise get grouped together:
Runtime schema compilation
versus
Build-time generation from TypeScript typesThat distinction becomes particularly important when we look at typia.
6. π’ ArkType: Expressing Runtime Rules in a TypeScript-Like Syntax
ArkType uses a different approach to describing schemas.
Instead of relying exclusively on chained method calls, it allows us to express type constraints using concise, TypeScript-like strings.
import { type } from "arktype";
export const UserSchema = type({
id: "string",
name: "0 < string <= 100",
age: "18 <= number.integer <= 120",
role: "'admin' | 'user'",
tags: "string[]",
profile: {
bio: "string",
active: "boolean",
},
}).onDeepUndeclaredKey("reject");
export const isUser = (input: unknown) =>
UserSchema.allows(input);
export const parseUser = (input: unknown) =>
UserSchema(input);
export const ArkErrors = type.errors;Compare the following expression:
z.int().min(18).max(120);with:
"18 <= number.integer <= 120";Both describe an integer within the required range, but the authoring experience is different.
Neither style is automatically superior. The choice depends partly on which representation makes the intended contract clearest to your team.
For developers who find TypeScript-like expressions natural, ArkType's syntax can be particularly readable.
Its allows() operation can act as a type guard, while invoking the schema directly returns validated output or an error collection.
ArkType also has an optimization mechanism worth mentioning: it can precompile validation traversal logic at runtime when the environment permits new Function.
This allows it to specialize validation rather than repeatedly interpreting the same general schema structure.
However, ArkType's architecture is still different from typia's. ArkType begins with a runtime representation of the type, while typia generates validation code from TypeScript types during the build process.
7. π typia: Generating Validation Code During the Build
typia is the most architecturally different approach in this comparison.
Instead of defining a conventional runtime schema object, we describe the contract using TypeScript types and typia's tags.
import typia, { type tags } from "typia";
type Utf16Name = tags.TagBase<{
kind: "utf16Name";
target: "string";
value: undefined;
validate: "$input.length >= 1 && $input.length <= 100";
}>;
export interface User {
id: string;
name: string & Utf16Name;
age: number &
tags.Type<"uint32"> &
tags.Minimum<18> &
tags.Maximum<120>;
role: "admin" | "user";
tags: string[];
profile: {
bio: string;
active: boolean;
};
}
export const isUser = typia.createEquals<User>();
export const validateUser = typia.createValidateEquals<User>();Here, the TypeScript type and its associated tags form the source of truth.
During the build, typia transforms:
typia.createEquals<User>();into specialized validation code.
The resulting implementation doesn't need a general-purpose runtime schema interpreter to walk a User schema object.
That can reduce runtime overhead, but it introduces an important requirement: the build must support typia's transformation process.
The official setup used for this comparison relies on TypeScript 7 and the ttsc/typia transform integration. Running ordinary tsc by itself doesn't perform that transformation.
In my verification environment, the initial typia build also required compiling a Go source plugin, which took several minutes.
That setup time isn't included in the runtime benchmark, but it matters when deciding whether to adopt the library.
There was another contract mismatch to address.
typia's built-in MinLength and MaxLength didn't enforce our UTF-16 code-unit requirement. I therefore used a custom tag for the name field.
Once again, two validation rules that look equivalent at first glance can have different runtime meanings.
πΉ A Surprise: Even String Length Can Mean Different Things
This was one of the most interesting findings in the comparison.
Consider this JavaScript expression:
"π".repeat(51).length;
// 102JavaScript's string.length counts UTF-16 code units.
Under our contract, a name can contain no more than 100 UTF-16 code units. The string above should therefore fail validation.
It did fail with:
The handwritten guard.
is-kit.Runtypes.
Valibot.
ArkType.
However, the original Zod and typia implementations accepted the same string when using their built-in length constraints.
Why?
Because those built-in constraints count Unicode code points rather than UTF-16 code units.
For our example:
51 emoji
= 51 Unicode code points
= 102 UTF-16 code unitsThe different outcomes don't automatically mean one implementation is defective. The validators were applying different definitions of length.
To make the comparison fair, I adjusted the Zod example to use .refine() and typia to use a custom tag.
There is another Unicode complication: code points aren't necessarily the same as the number of characters a person visually perceives, because a displayed character can contain multiple code points.
The key lesson is this:
Schemas that look equivalent don't necessarily enforce equivalent runtime contracts.
When comparing validators, you need to test what the rules actually meanβnot just whether the APIs look similar.
So, What Are We Really Comparing?
By this point, it's clear that these seven approaches aren't simply different versions of the same thing.
They operate at different layers.
Approach | Source of truth | Typical success API | Structured failures | Transformation model | Build requirement |
|---|---|---|---|---|---|
Handwritten guard | Type and handwritten checks | Predicate | Manual | Manual | None |
is-kit | Composed guards | Predicate / | Basic success/failure result | Guard-oriented | None |
Runtypes | Runtype object |
| Yes | Parsers | None |
Valibot | Schema functions |
| Yes | Schema pipelines | None |
Zod | Schema objects |
| Yes | Transforms / codecs | No build transform; optional runtime |
ArkType | Runtime type expressions |
| Yes | Morphs | No build transform; runtime precompilation when available |
typia | TypeScript types and tags | Generated predicates / validation results | Through validation APIs | Build-generated functions | Build transform required |
This is why I wouldn't describe these options as a simple ladder where each successive tool is an upgrade.
A schema library isn't automatically a better type guard. A generated validator isn't automatically a better schema.
They solve overlapping problems, but they do so through different models.
β What Did the Tests Actually Confirm?
The comparison used a reproducible test harness, including a lockfile, shared fixtures, test probes, and generated results.
The repository is available at:
typescript-validator-comparison
To reproduce the recorded snapshot:
git clone https://github.com/nyaomaru/typescript-validator-comparison.git
cd typescript-validator-comparison
git checkout --detach b26350d01fd18cb77d55a95e2f3b112657f0d305
corepack pnpm install --frozen-lockfile
corepack pnpm verifyThe pnpm verify command runs linting, strict type checking, fixture tests, bundle measurements, benchmarks, JavaScript-only probes, and report generation.
The reported numbers come from that particular run. Running the same tests on another machine can produce different timing results.
Test environment
Date: 2026-10-23
Node: 24.22.1
TypeScript: 7.0.2
pnpm: 11.22.0
ttsc: 0.31.3
tsbuild: 0.28.2Package versions
Package | Version |
|---|---|
is-kit | 1.15.3 |
Runtypes | 7.0.5 |
Valibot | 1.5.0 |
Zod | 4.6.5 |
ArkType | 2.2.8 |
typia | 15.1.0 |
The shared test matrix contained 35 JSON fixtures covering:
Valid user objects.
Age boundaries.
Name-length boundaries.
Emoji-length cases.
Incorrect primitive types.
Missing fields.
Invalid role values.
Invalid array elements.
Unexpected root properties.
Unexpected nested properties.
Non-object inputs.
The resulting number of boolean checks was:
35 fixtures Γ 7 validators = 245 checksAll 245 checks passed.
The harness also tested input mutation, additional APIs, strict TypeScript compilation, linting, builds, type narrowing, and bundled output behavior.
The important qualification is that the implementations agreed for the JSON-shaped contract being tested. That doesn't establish identical behavior for every possible JavaScript value.
π§© Another Finding: "Exact Object Validation" Has Limits
I also examined inputs that fall outside the ordinary JSON-decoded data model.
Here are four examples:
const sparseTags = { ...valid, tags: new Array(2) };
const inheritedFields = Object.create(valid);
const extraSymbol = { ...valid, [Symbol("extra")]: true };
const extraUndefined = { ...valid, extra: undefined };These probes test sparse arrays, inherited properties, symbol properties, and extra properties whose values are undefined.
The repository also includes nine additional probes, including non-enumerable properties and getters that throw errors.
Here are the results for the four examples above.
Probe | Native guard | is-kit | Runtypes | Valibot | Zod | ArkType | typia |
|---|---|---|---|---|---|---|---|
Sparse | Accept | Reject | Accept | Reject | Reject | Reject | Accept |
All fields inherited | Reject | Reject | Reject | Accept | Accept | Accept | Accept |
Extra symbol property | Accept | Accept | Reject | Accept | Accept | Reject | Accept |
Extra key with | Reject | Reject | Reject | Reject | Reject | Reject | Accept |
All seven implementations accepted the extra non-enumerable property tested. All seven also threw when accessing a getter that throws.
These results don't mean that one validator is universally correct and the others are broken.
They demonstrate that the phrase "exact object validation" needs a clearly defined scope.
For example, the handwritten guard uses:
Object.keys(value);That returns enumerable string keys, but it doesn't include symbol keys or non-enumerable properties.
Likewise:
value.tags.every(...);doesn't visit empty slots in a sparse array.
Those behaviors may be perfectly reasonable when the expected inputs are JSON-decoded objects. They don't amount to a universal policy for every object JavaScript can produce.
That's another reason to define your input domain before selecting or benchmarking a validator.
π¦ Bundle Size: How Much JavaScript Does Each Approach Ship?
Next, I measured the browser bundles.
Each browser-targeted entry exported only the validate function. Every implementation was bundled with the same esbuild configuration:
Browser platform.
ESM output.
ES2022 target.
Minification.
Tree shaking.
Removal of legal comments.
I then recorded raw, gzip-compressed, and Brotli-compressed sizes.
Validator | Raw bytes | gzip bytes | Brotli bytes |
|---|---|---|---|
Handwritten guard | 588 | 337 | 295 |
is-kit | 3,421 | 1,530 | 1,423 |
Runtypes | 16,667 | 5,188 | 4,657 |
Valibot | 5,722 | 1,853 | 1,675 |
Zod | 89,888 | 26,212 | 23,331 |
ArkType | 155,549 | 47,603 | 41,956 |
typia | 772 | 403 | 339 |
There are several important qualifications to these figures.
1. These are isolated bundle costs
If your application already includes Zod, adding another schema doesn't necessarily increase the bundle by the full 26 KB gzip shown here.
The table measures standalone entry bundles, not the marginal cost of adding one schema to an existing application.
2. The Zod measurement uses regular Zod
The results don't include Zod Mini.
Consequently, this isn't a direct answer to the question of whether Valibot is smaller than the smallest possible Zod configuration.
3. Generated code still has a size
typia produced a particularly small guard bundle in this test: 772 raw bytes.
However, the output still included generated code and a uint32 helper.
Code generation doesn't mean the resulting validator has zero cost.
Even with these limitations, the measurements demonstrate how differently the libraries are architected.
β‘ Runtime Performance: What Did the Benchmarks Show?
I was initially hesitant to include runtime measurements because validator benchmarks can be misleading.
However, since the test environment already used the same data contract and fixtures for all implementations, I ran a small steady-state benchmark.
Three scenarios were tested:
A valid user object.
An object with an incorrect
id.An object with an incorrect nested
profile.active.
Each library ran in a separate Node.js process.
For each scenario, the benchmark used:
20,000 warm-up calls.
Nine measured samples.
50,000 calls per sample.
Schemas and validators were created before the measured loop.
The following values represent median nanoseconds per call, with the minimum and maximum shown in parentheses.
Validator | Valid user | Incorrect | Incorrect |
|---|---|---|---|
Handwritten guard | 79.9 (77.3β114.1) | 73.6 (72.1β84.9) | 80.8 (79.0β96.3) |
is-kit | 232.0 (225.7β257.5) | 34.5 (33.1β38.9) | 210.3 (203.6β218.1) |
Runtypes | 5804.0 (5425.5β6298.0) | 9221.8 (8443.2β11063.2) | 10101.2 (9287.6β10503.5) |
Valibot | 951.2 (425.2β1782.7) | 200.2 (96.1β422.3) | 1112.1 (648.4β1538.1) |
Zod | 612.6 (351.3β1203.5) | 1491.6 (862.9β2824.6) | 2208.5 (1592.4β4757.4) |
ArkType | 291.5 (278.1β614.4) | 9.6 (6.6β17.7) | 12.0 (11.3β37.6) |
typia | 21.9 (20.5β46.1) | 2.0 (1.9β6.4) | 11.5 (10.8β17.2) |
These numbers should not be interpreted as proof that typia is universally the fastest validator.
This is a microbenchmark involving repeated validation of small, predictable objects. V8 can optimize such workloads very aggressively.
A result of 2.0 nanoseconds per call shouldn't be treated as a portable estimate of validation cost in a real application.
There is also a difference in what each success operation does:
The handwritten guard uses a predicate.
is-kit uses a predicate.
Runtypes uses
.guard().Valibot uses
is().Zod uses
safeParse(...).success.ArkType uses
allows().typia uses a generated equality guard.
Those operations don't necessarily perform exactly the same amount of work.
Still, the results demonstrate how implementation architecture and failure paths can affect performance.
For example:
The handwritten guard checks exact object keys before rejecting an incorrect
id.ArkType's invalid-input paths were considerably cheaper than its valid-input path in this test.
typia's generated guard had very low steady-state overhead in this workload.
Runtypes' richer validation machinery was more expensive in this particular benchmark.
Those observations are useful, but they don't establish a universal performance ranking.
Real applications have different data structures, input distributions, error-handling requirements, and execution environments.
So, Which Approach Would I Choose? π€
After examining the implementations, the decision becomes less complicated when we start with the actual requirement.
Need one small type-narrowing check?
I'd start with a handwritten guard.
if (isUser(input)) {
// input is User
}When the problem is small, avoiding an additional dependency is an advantage.
Need reusable guards throughout the codebase?
This is where is-kit becomes interesting.
values.filter(isName);
if (isAge(value)) {
// ...
}The problem might not be that you need a schema. It might simply be that you're repeatedly rebuilding the same predicates and composition helpers.
Want a runtime validator object?
Runtypes is worth considering if you'd like one object that supports operations such as:
guard
check
parse
inspect
assertThat provides a different workflow from maintaining separate boolean guards.
Want schema validation with a modular API?
Valibot is a strong candidate, particularly when client bundle size and tree shaking matter to the project.
Need schemas that integrate with a broader ecosystem?
Zod is worth considering when validation schemas connect to forms, APIs, metadata, codecs, and other application infrastructure.
If bundle size is a concern, evaluate Zod Mini separately rather than relying on measurements of regular Zod alone.
Prefer expressing constraints using TypeScript-like syntax?
ArkType offers a distinctive authoring style.
For example:
"18 <= number.integer <= 120";provides a different way to communicate the same numeric constraint compared with a chain of schema methods.
Want validators generated from TypeScript types during the build?
typia is worth investigating.
However, its build integration must be part of the decision. The performance characteristics of generated code don't eliminate the need to evaluate the tooling required to produce it.
Final Thoughts
After comparing these seven approaches, my main takeaway is that they're not interchangeable tools arranged on a scale from worst to best.
They overlap, but they solve validation problems at different layers.
The real challenge isn't simply getting every implementation to compile. It's making sure every implementation enforces the same contract.
Before comparing bundle sizes or benchmark results, ask yourself:
What exactly must the input satisfy?
Do I only need type narrowing, or do I need parsing and structured errors?
Will I need transformations or schema integrations?
How important are bundle size and runtime performance?
Am I comfortable with the tooling required by the chosen approach?
My guiding principle is simple: use the smallest model that adequately represents the boundary you're trying to validate.
Sometimes that means a handwritten type guard. Sometimes it means a schema library. And sometimes a build-time generated validator makes more sense.
The right choice depends on what your application actually needsβnot simply which library wins a benchmark.
Which approach would you choose for your next TypeScript project, and why?
Thanks for reading! π€


Discussion
Join the conversation
Sign in to comment, reply, and interact with the community.