Fast TypeScript schema validation, with the rich constraints other validators can't inline.
Config-object schemas compiled to one monomorphic function — zero-allocation hot
path, Standard Schema, and JSON Schema export — for Node, Bun & the browser.
Website · npm · API reference · Constraints · Examples · Issues
TypKit is a TypeScript validation library. You describe a schema by chaining
readable constraints (or with an equivalent config object); the first time you run
it, the whole tree is compiled into a single monomorphic function via
new Function. Chaining is build-time only — it compiles to the identical
validator — so the happy path allocates nothing, and rich constraints (maxLines,
charset, blockWords, formats, ranges) compile to inline code instead of
closures. Every schema is a Standard Schema and
exports JSON Schema.
import { t } from '@myrialabs/typkit';
const Comment = t.object({
author: t.string().minLength(3).maxLength(20).charset('a-z0-9_'),
email: t.string().email(),
body: t.string().nonEmpty().maxLines(500).blockWords(BANNED),
rating: t.int().min(1).max(5),
tags: t.string().array().optional(),
visibility: t.enum(['public', 'private']),
});
Comment.check(value); // boolean — zero-allocation hot path
Comment.assert(value); // throws on failure, returns typed value
Comment.parse(value); // { value } | { issues }
Comment['~standard'].validate(value); // Standard Schema — Elysia, Hono, tRPC
Comment.toJsonSchema(); // OpenAPI / JSON Schema
type Comment = t.infer<typeof Comment>;bun add @myrialabs/typkit # or: npm install @myrialabs/typkit- Rich constraints that stay fast.
maxLines,charset,blockWords,allowedWords, and inline format checks (email, uuid, ipv4, LuhncreditCard, …) compile to literal loops. Competitors fall back to.refine()/.check()/.narrow()closures — 2.3–3.2× slower — and TypeBox can't express them at all. - Zero-allocation hot path.
check()returns a boolean; a validated value is never wrapped in a new object, and an issue path is built only when something fails. It sits in the compiled fast tier with ArkType and TypeBox, and runs 8–90× faster than Zod, Valibot, and effect/Schema — seebench-results.md. - Works everywhere, no adapter. Standard Schema means Elysia, Hono, tRPC, react-hook-form, and TanStack Form accept a schema directly.
- JSON Schema in, OpenAPI out.
toJsonSchema()maps 1:1 from the config object, so frameworks generate OpenAPI / Swagger straight from your validation schema. - Honest type inference.
t.infer<>is full and precise, and stays light ontsc(about a quarter of ArkType's instantiations). - Self-documenting fluent API. Chain readable constraints —
t.int().min(1).max(5)— with no crypticgte/lt:min/maxare inclusive,greaterThan/lessThanexclusive. Chaining is build-time only, so it compiles to the same validator as the equivalent config object and costs nothing at runtime. - Zero runtime dependencies. Node 18+, Bun, and the browser.
- Guide — from first schema to framework integration.
- API reference — every builder and method.
- Constraints — every inline rule and format.
- Frameworks — Elysia, Hono, tRPC, forms.
- JSON Schema — OpenAPI / Swagger export.
- Comparison — TypKit vs Zod, ArkType, TypeBox, Valibot.
- Benchmarks — reproducible numbers.
MIT © Myria Labs