🛵 Universal adapter for TypeScript schema validation.
See the code
Universal adapter for schema validation
✨ https://typeschema.com ✨
Quickstart • Coverage • API • GitHub • npm
When fetching data from an external source, it's important to verify its integrity. This happens when processing user inputs, calling third-party APIs, loading configuration files, and so on. And the thing is: Typescript doesn't come with runtime validation. Any type assertions are removed at compile-time.
As a result, developers turn to third-party validation libraries. But that landscape is fragmented, lacking a single best option. Each offers different trade-offs on developer experience, bundle size, and community support.
TypeSchema enables writing code that works with any validation library out-of-the-box. It provides a universal adapter for interacting with any validation schema, decoupling from implementation specifics and increasing compatibility.
import {validate} from '@typeschema/main';
import {z} from 'zod';
import {string} from 'valibot';
const zodSchema = z.string();
await validate(zodSchema, '123');
// ^? {success: true, data: '123'}
const valibotSchema = string();
await validate(valibotSchema, 123);
// ^? {success: false, issues: [...]}
We value flexibility, which is why there are multiple ways of using TypeSchema:
@typeschema/valibot): Best pick for end developers, when the validation library is known ahead of time. This is particularly useful for supporting more validation libraries on tRPC.@typeschema/main: Recommended for library maintainers. Any validation library can be used, but adapters have to be explicitly installed. This allows end developers to trade-off between coverage and bundle size.@typeschema/all: Easiest to use. All adapters are automatically installed, including future ones. This is a drop-in replacement for the deprecated @decs/typeschema.| Project | Popularity | Infer | InferIn | Validation | Serialization | Adapter | Downloads |
|---|---|---|---|---|---|---|---|
| zod | ✅ | ✅ | ✅ | ✅ | @typeschema/zod | ||
| yup | ✅ | ✅ | ✅ | ✅ | @typeschema/yup | ||
| joi | 🧐 | 🧐 | ✅ | ✅ | @typeschema/joi | ||
| ajv | ✅ | ✅ | ✅ | ✅ | @typeschema/json | ||
| class-validator | ✅ | ✅ | ✅ | 🧐 | @typeschema/class-validator | ||
| effect | ✅ | ✅ | ✅ | ✅ | @typeschema/effect | ||
| superstruct | ✅ | 🧐 | ✅ | 🧐 | @typeschema/superstruct | ||
| io-ts | ✅ | ✅ | ✅ | 🧐 | @typeschema/io-ts | ||
| valibot | ✅ | ✅ | ✅ | ✅ | @typeschema/valibot | ||
| typebox | ✅ | ✅ | ✅ | ✅ | @typeschema/typebox | ||
| typia | ✅ | ✅ | ✅ | 🧐 | @typeschema/function | ||
| arktype | ✅ | ✅ | ✅ | 🧐 | @typeschema/arktype | ||
| ow | ✅ | ✅ | ✅ | 🧐 | @typeschema/ow | ||
| deepkit | 🧐 | 🧐 | ✅ | 🧐 | @typeschema/deepkit | ||
| runtypes | ✅ | ✅ | ✅ | 🧐 | @typeschema/runtypes | ||
| fastest-validator | 🧐 | 🧐 | ✅ | 🧐 | @typeschema/fastest-validator | ||
| vine | ✅ | ✅ | ✅ | 🧐 | @typeschema/vine | ||
| suretype | ✅ | ✅ | ✅ | ✅ | @typeschema/suretype | ||
| valita | ✅ | ✅ | ✅ | 🧐 | @typeschema/valita |
[!NOTE] Don't see your favorite validation library? We welcome PRs! Otherwise, please file an issue to help us prioritize. 🙌
Infer<TSchema>: Extracts the output type of a schemaInferIn<TSchema>: Extracts the input type of a schemawrap(schema): Returns the wrapped schema with access to its operationsvalidate(schema, data): Returns the validated data or a list of validation issuesassert(schema, data): Returns the validated data or throws an AggregateErrortoJSONSchema(schema): Converts the schema into the equivalent JSON schema5,149 followers · starred Jul 2023
3,920 followers · starred Aug 2023
477 followers · starred Sep 2025
1,959 followers · starred Jul 2023
🛵 Universal adapter for TypeScript schema validation.
See the code
Universal adapter for schema validation
✨ https://typeschema.com ✨
Quickstart • Coverage • API • GitHub • npm
When fetching data from an external source, it's important to verify its integrity. This happens when processing user inputs, calling third-party APIs, loading configuration files, and so on. And the thing is: Typescript doesn't come with runtime validation. Any type assertions are removed at compile-time.
As a result, developers turn to third-party validation libraries. But that landscape is fragmented, lacking a single best option. Each offers different trade-offs on developer experience, bundle size, and community support.
TypeSchema enables writing code that works with any validation library out-of-the-box. It provides a universal adapter for interacting with any validation schema, decoupling from implementation specifics and increasing compatibility.
import {validate} from '@typeschema/main';
import {z} from 'zod';
import {string} from 'valibot';
const zodSchema = z.string();
await validate(zodSchema, '123');
// ^? {success: true, data: '123'}
const valibotSchema = string();
await validate(valibotSchema, 123);
// ^? {success: false, issues: [...]}
We value flexibility, which is why there are multiple ways of using TypeSchema:
@typeschema/valibot): Best pick for end developers, when the validation library is known ahead of time. This is particularly useful for supporting more validation libraries on tRPC.@typeschema/main: Recommended for library maintainers. Any validation library can be used, but adapters have to be explicitly installed. This allows end developers to trade-off between coverage and bundle size.@typeschema/all: Easiest to use. All adapters are automatically installed, including future ones. This is a drop-in replacement for the deprecated @decs/typeschema.| Project | Popularity | Infer | InferIn | Validation | Serialization | Adapter | Downloads |
|---|---|---|---|---|---|---|---|
| zod | ✅ | ✅ | ✅ | ✅ | @typeschema/zod | ||
| yup | ✅ | ✅ | ✅ | ✅ | @typeschema/yup | ||
| joi | 🧐 | 🧐 | ✅ | ✅ | @typeschema/joi | ||
| ajv | ✅ | ✅ | ✅ | ✅ | @typeschema/json | ||
| class-validator | ✅ | ✅ | ✅ | 🧐 | @typeschema/class-validator | ||
| effect | ✅ | ✅ | ✅ | ✅ | @typeschema/effect | ||
| superstruct | ✅ | 🧐 | ✅ | 🧐 | @typeschema/superstruct | ||
| io-ts | ✅ | ✅ | ✅ | 🧐 | @typeschema/io-ts | ||
| valibot | ✅ | ✅ | ✅ | ✅ | @typeschema/valibot | ||
| typebox | ✅ | ✅ | ✅ | ✅ | @typeschema/typebox | ||
| typia | ✅ | ✅ | ✅ | 🧐 | @typeschema/function | ||
| arktype | ✅ | ✅ | ✅ | 🧐 | @typeschema/arktype | ||
| ow | ✅ | ✅ | ✅ | 🧐 | @typeschema/ow | ||
| deepkit | 🧐 | 🧐 | ✅ | 🧐 | @typeschema/deepkit | ||
| runtypes | ✅ | ✅ | ✅ | 🧐 | @typeschema/runtypes | ||
| fastest-validator | 🧐 | 🧐 | ✅ | 🧐 | @typeschema/fastest-validator | ||
| vine | ✅ | ✅ | ✅ | 🧐 | @typeschema/vine | ||
| suretype | ✅ | ✅ | ✅ | ✅ | @typeschema/suretype | ||
| valita | ✅ | ✅ | ✅ | 🧐 | @typeschema/valita |
[!NOTE] Don't see your favorite validation library? We welcome PRs! Otherwise, please file an issue to help us prioritize. 🙌
Infer<TSchema>: Extracts the output type of a schemaInferIn<TSchema>: Extracts the input type of a schemawrap(schema): Returns the wrapped schema with access to its operationsvalidate(schema, data): Returns the validated data or a list of validation issuesassert(schema, data): Returns the validated data or throws an AggregateErrortoJSONSchema(schema): Converts the schema into the equivalent JSON schema5,149 followers · starred Jul 2023
3,920 followers · starred Aug 2023
477 followers · starred Sep 2025
1,959 followers · starred Jul 2023