Stage 02 · Test · Researched comparison
Best TypeScript Validation Libraries in 2026
Zod is the first pick for most teams. It gives you schema definitions and TypeScript types from one source, with no code generation step, and it suits API input checks, form validation and config parsing. Valibot is a strong alternative when bundle size matters, since it is tree-shakeable and ships small. Yup remains a reasonable choice for React form stacks that already depend on it. All three are open source and free.
By Shihab Mia
Published 27 Nov 2026 · 8 tools compared
We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.
Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.
Key takeaways
- Zod, Valibot, Yup, Joi, io-ts, class-validator, ArkType and Ajv are all free and open source, so cost is not the deciding factor.
- Zod and Valibot infer TypeScript types from the schema, which keeps runtime checks and compile-time types in sync.
- Valibot and Zod are tree-shakeable; Ajv compiles JSON Schema and is the fastest fit when schemas already exist as JSON.
- None of these libraries send your data anywhere; validation runs in your process, so secrets stay local.
Who each pick is for
- General-purpose schema validation with type inferenceZod
- Small client bundles with modular schemasValibot
- Form validation in React projectsYup
- Server-side validation in Node.js servicesJoi
- Functional codebases that want runtime typesio-ts
- Decorator-based validation in class modelsclass-validator
- TypeScript-native syntax with fast parsingArkType
- Validating against existing JSON Schema documentsAjv
Comparison
| Tool | Best for | Standout feature | Listed starting price | Free plan or trial |
|---|---|---|---|---|
| 1Zod | General-purpose schema validation with type inference | Types inferred from schemas | Free (open source) | Free plan |
| 2Valibot | Small client bundles with modular schemas | Tree-shakeable API with small footprints | Free (open source) | Free plan |
| 3Yup | Form validation in React projects | Mature and widely used with form libraries | Free (open source) | Free plan |
| 4Joi | Server-side validation in Node.js services | Rich built-in rules and detailed error messages | Free (open source) | Free plan |
| 5io-ts | Functional codebases that want runtime types | Precise runtime type representation | Free (open source) | Free plan |
| 6class-validator | Decorator-based validation in class models | Decorator syntax fits class-based models | Free (open source) | Free plan |
| 7ArkType | TypeScript-native syntax with fast parsing | Schema syntax mirrors TypeScript types | Free (open source) | Free plan |
| 8Ajv | Validating against existing JSON Schema documents | Implements JSON Schema standards | Free (open source) | Free plan |
How we picked
We compared libraries on fit for runtime validation in TypeScript projects, supported platforms, licence and price, whether types are inferred from schemas, bundle and tree-shaking behavior, and documented limits. Sources are official documentation, project repositories and public pricing pages. All listed projects are open source and free. Prices and features change, so confirm details on the vendor site before you commit.
The tools, one by one
Zod
Best for general-purpose schema validation with type inference

What it is and where it fits
Zod lets you declare a schema once and get both a runtime validator and a TypeScript type. You write `z.object({...})`, call `.parse()` or `.safeParse()`, and the parsed value carries the inferred type. It works in Node.js, Deno, Bun and browsers, and needs no build plugin or decorator setup.
It fits API request bodies, environment variables, form data and third-party responses. Errors are structured, so you can map them to field-level messages. The main tradeoff is size: importing Zod pulls in more code than a tree-shaken Valibot schema, which matters for client bundles. Skip it if you need to validate against existing JSON Schema documents, where Ajv is the better fit.
Standout: Types inferred from schemas
Free (open source), as listed by the vendor (Zod website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Types inferred from schemas
- large ecosystem and integrations
Drawbacks
- Larger bundle than tree-shakeable rivals
- schema syntax is its own DSL
Skip it if this limit matters to you: larger bundle than tree-shakeable rivals.
Verdict. A sensible pick for general-purpose schema validation with type inference.
Valibot
Best for small client bundles with modular schemas

What it is and where it fits
Valibot is a modular schema library. Each validator is a separate function, so bundlers drop what you do not import. The project documents bundle sizes for common schemas that are a fraction of a full library import, which makes it a candidate for browser-side form validation.
The API resembles Zod, so moving between them is not a large rewrite. It supports TypeScript type inference, async validation and pipelines for transforms. It runs anywhere JavaScript runs. The catch is ecosystem maturity: fewer third-party adapters and integrations than Zod, and the API has shifted between major releases, so pin versions and read the migration notes. Choose it when payload size is a real constraint.
Standout: Tree-shakeable API with small footprints
Free (open source), as listed by the vendor (Valibot website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Tree-shakeable API with small footprints
- similar mental model to Zod
Drawbacks
- Smaller ecosystem than Zod
- API surface changed across major versions
Skip it if this limit matters to you: smaller ecosystem than Zod.
Verdict. A sensible pick for small client bundles with modular schemas.
Yup
Best for form validation in React projects

What it is and where it fits
Yup is a schema builder with a chained API, such as `string().required().min(3)`. It has long been the default schema library in React form stacks, and many form libraries and examples assume it. It runs in Node.js and browsers and supports async tests.
Its type inference is less precise than Zod's or Valibot's, so you often declare types separately and risk drift. The package is not designed for aggressive tree-shaking. If you are starting fresh with no form-library dependency, Zod or Valibot usually give tighter types. Keep Yup when your forms already use it and the migration cost outweighs the benefit.
Standout: Mature and widely used with form libraries
Free (open source), as listed by the vendor (Yup website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Mature and widely used with form libraries
- readable chained schema syntax
Drawbacks
- Type inference is weaker than Zod or Valibot
- bundle is not tree-shakeable by default
Skip it if this limit matters to you: type inference is weaker than Zod or Valibot.
Verdict. A sensible pick for form validation in React projects.
Joi
Best for server-side validation in Node.js services

What it is and where it fits
Joi is a server-oriented validation library for Node.js with a wide set of built-in rules for strings, numbers, dates, arrays and objects. It produces detailed error objects and supports custom messages and extensions.
Joi does not infer TypeScript types from schemas, so you maintain types alongside the schema or use a separate type definition. It is also large for browser use, so it is best kept on the server. It suits backend teams that want extensive validation rules without writing custom checks, and projects already standardized on it. For shared client and server schemas with inferred types, Zod or Valibot are a better match.
Standout: Rich built-in rules and detailed error messages
Free (open source), as listed by the vendor (Joi website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Rich built-in rules and detailed error messages
- long track record in Node
Drawbacks
- No TypeScript type inference from schemas
- browser bundle is heavy
Skip it if this limit matters to you: no TypeScript type inference from schemas.
Verdict. A sensible pick for server-side validation in Node.js services.
io-ts
Best for functional codebases that want runtime types

What it is and where it fits
io-ts encodes types as runtime values, so a codec both validates and decodes data. It pairs with fp-ts and suits teams already using functional patterns. Each codec carries its TypeScript type, and decoding returns an Either rather than throwing.
The API is more verbose than Zod's and assumes comfort with functional abstractions. It runs in Node.js and browsers. If your codebase does not use fp-ts, the learning cost is hard to justify over Zod. Choose it when you want explicit codecs and error handling through Either types, and your team is already fluent in that style.
Standout: Precise runtime type representation
Free (open source), as listed by the vendor (io-ts website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Precise runtime type representation
- works well with fp-ts
Drawbacks
- Steeper learning curve
- verbose compared with Zod
Skip it if this limit matters to you: steeper learning curve.
Verdict. A sensible pick for functional codebases that want runtime types.
class-validator
Best for decorator-based validation in class models

What it is and where it fits
class-validator validates class instances using property decorators such as `@IsString()` and `@MinLength()`. It is widely used with NestJS, where DTO classes carry validation rules and a pipe runs the checks. It depends on class-transformer for plain-object conversion.
It requires TypeScript decorator support and a class-based model, so it does not fit functional or plain-object codebases well. Validation rules live on the class, which keeps models and rules together but couples them. It runs in Node.js and browsers. Pick it if you use NestJS or already model requests as classes; otherwise a schema library is simpler.
Standout: Decorator syntax fits class-based models
Free (open source), as listed by the vendor (class-validator website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Decorator syntax fits class-based models
- common in NestJS projects
Drawbacks
- Requires decorators and class models
- not a standalone schema builder
Skip it if this limit matters to you: requires decorators and class models.
Verdict. A sensible pick for decorator-based validation in class models.
ArkType
Best for typeScript-native syntax with fast parsing

What it is and where it fits
ArkType defines schemas using syntax close to TypeScript type annotations, such as `type("string|number")`. It parses those definitions at runtime and infers precise types. The project emphasizes parser performance and low overhead.
It runs in Node.js and browsers and supports narrowing and morphs. The ecosystem is smaller than Zod's, and the string-based syntax takes adjustment if you expect an object builder. It suits teams that want schemas to read like TypeScript types and are comfortable adopting a younger library. Check release stability and integration support before standardizing on it.
Standout: Schema syntax mirrors TypeScript types
Free (open source), as listed by the vendor (ArkType website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Schema syntax mirrors TypeScript types
- strong type inference
Drawbacks
- Younger project with a smaller ecosystem
- syntax can be unfamiliar
Skip it if this limit matters to you: younger project with a smaller ecosystem.
Verdict. A sensible pick for typeScript-native syntax with fast parsing.
Ajv
Best for validating against existing JSON Schema documents

What it is and where it fits
Ajv validates data against JSON Schema. It compiles schemas into validation functions, which makes repeated validation fast. It supports JSON Schema drafts and is common in API gateways, config validation and OpenAPI tooling.
Schemas are JSON, so they can be shared across languages and generated from specifications. Authoring them by hand is more verbose than Zod, and TypeScript type inference requires separate tools such as json-schema-to-typescript. It runs in Node.js and browsers. Choose Ajv when JSON Schema already exists in your stack; choose Zod or Valibot when you want types and validation from one TypeScript source.
Standout: Implements JSON Schema standards
Free (open source), as listed by the vendor (Ajv website). Confirm the current plan price before you buy.
Free plan. Plans change, so confirm on the vendor's pricing page before you buy.
Benefits
- Implements JSON Schema standards
- compiles schemas for speed
Drawbacks
- JSON Schema is verbose to author by hand
- type inference needs extra tooling
Skip it if this limit matters to you: JSON Schema is verbose to author by hand.
Verdict. A sensible pick for validating against existing JSON Schema documents.
Who should use what
If you want one schema for types and runtime checks across client and server, start with Zod. If browser bundle size is a hard constraint, use Valibot. If your React forms already depend on Yup, keep it rather than rewrite. If you validate against JSON Schema or OpenAPI documents, use Ajv. Teams on NestJS with DTO classes should look at class-validator, and functional codebases using fp-ts may prefer io-ts.
Questions to settle before you buy
What to check before you buy
- Confirm the library infers TypeScript types from schemas, or plan how you will keep types in sync.
- Check bundle size impact for client-side use and whether the package tree-shakes.
- Verify error output shape fits your API error format and form field mapping.
- Check async validation support if you need database or network checks.
- Review the licence and release cadence, and pin versions before upgrading majors.
FAQ
Do I need a validation library if I use TypeScript?
Yes, for untrusted input. TypeScript types are erased at runtime, so data from APIs, forms, environment variables and files is unchecked. A validation library verifies that data at runtime and can infer types from the schema, keeping the two in sync.
Which library has the smallest bundle size?
Valibot is designed for tree-shaking, so only the validators you import are bundled. Zod is also tree-shakeable but generally larger for equivalent schemas. Measure with your own bundler and schema before deciding, since results depend on which features you use.
Can I use these libraries in the browser?
Zod, Valibot, Yup, io-ts, ArkType and Ajv run in browsers. Joi is heavy for client bundles and is usually kept server-side. class-validator needs decorator support and class models. All of them validate locally in your process and do not send data to a third party.
Do any of these libraries cost money?
No. All eight listed projects are open source and free to use. Some commercial products and hosted services exist around JSON Schema and API tooling, but the libraries themselves do not require a paid plan.
How do I migrate from Yup to Zod?
Rewrite each schema in Zod syntax, replace `.validate()` calls with `.parse()` or `.safeParse()`, and map error objects to your existing form error format. Run both libraries in parallel on the same inputs during the transition to confirm behavior matches before removing Yup.
Sources we checked
Method: how we score · editorial policy.
Change log. First published 27 Nov 2026.