What is typia?
typia turns your TypeScript types into runtime code at compile time.
Other libraries make you write your types twice — once in TypeScript and once as a schema, decorators, or guards. typia reads the type you already wrote and emits the validator, JSON serializer, schema, or decoder for you. One line, pure types, no duplication.
Here it is in action — the left tab is the source you write, the right tab is what typia generates for you at compile time:
TypeScript source
import typia, { tags } from "typia";
interface User {
id: string & tags.Format<"uuid">;
email: string & tags.Format<"email">;
age: number & tags.Type<"uint32"> & tags.Minimum<19>;
}
// One line, pure TypeScript types. No schema, no decorators.
export const check = typia.createIs<User>();No reflection at runtime, no schema file to maintain — just the exact comparisons your User type implies, inlined into the build. This is the core trick that every other typia feature builds on; see Pure TypeScript for the long story.
The right-hand “Compiled JavaScript” tab is produced by typia’s compile-time transform — stock
tscwill not produce it. To enable the transform, install one of the build paths in Setup (ttscfor TypeScript-Go,ts-patchfor the stable TypeScript v5/v6 release). Without setup, yourtypia.is<T>()call sites throw at runtime instead.

API surface
typia covers five feature areas, all driven by the same TypeScript-type-to-runtime-code transform:
- Super-fast runtime validators —
is/assert/validate(+ Equals strict variants) - Enhanced JSON — type-safe
assertParse, much fasterassertStringify, OpenAPI / JSON Schema generation - LLM function calling harness — class → tool schemas with lenient JSON parsing, type coercion, and validation feedback baked in
- Protocol Buffer codec — encode / decode +
.prototext emission from a TypeScript type - Random data generator — produce a value that satisfies the type, tags and all
// Runtime validators — write a type, get a checker
typia.is<T>(input); // boolean
typia.assert<T>(input); // throws TypeGuardError, otherwise returns input
typia.assertGuard<T>(input); // narrows the variable (`asserts input is T`)
typia.validate<T>(input); // returns IValidation<T> with every error path
// JSON — same idea, plus performance
typia.json.assertParse<T>(text); // safe JSON.parse + assert
typia.json.assertStringify<T>(obj); // ~10x faster JSON.stringify with type safety
typia.json.schemas<[T]>(); // emit OpenAPI/JSON Schema
// LLM function calling — turn a TypeScript class into tools
typia.llm.application<MyService>(); // full ILlmApplication with parse/coerce/validate
typia.llm.structuredOutput<T>(); // schema + parser + coercer + validator
typia.llm.parameters<T>(); // just the JSON schema
// Protocol Buffer — same again, in binary
typia.protobuf.assertEncode<T>(obj);
typia.protobuf.assertDecode<T>(bytes);
typia.protobuf.message<T>(); // emit .proto schema text
// Test data
typia.random<T>(); // generate a value that satisfies TBuild setup
The transformation above happens at compile time, so typia needs to be wired into the TypeScript build. There are two supported paths:
- TypeScript-Go (
@next) — usettscas a drop-in replacement fortsc. The Go-native compiler ships the typia transform on the side. - Stable TypeScript v5 / v6 — use
ts-patchto patch the stock JavaScript compiler so it can apply the same transform. This is the production path most teams ship today.
Bundlers (Vite, Next.js, Webpack, esbuild, Rollup, …) plug in through @ttsc/unplugin (modern) or @typia/unplugin (legacy). Babel and SWC can’t run a TypeScript transformer, so for those toolchains typia falls back to its generation mode, which writes the transformed .ts files ahead of time.
Whichever path you pick, the call sites in your code don’t change —
typia.is<T>,typia.assert<T>,typia.json.assertParse<T>, … always emit the same inline checks shown in What is typia? above. Setup is something you do once; the rest of the docs assume it’s done.
Where to go next
- Need to install it now? See Setup — pick TypeScript-Go (
ttsc) or the TS v6 legacy path. - Looking up an API? Jump straight to Validators, JSON, LLM, Protobuf, or Random.
- Building an agent? Start at LLM function calling and the function calling harness.
- Adopting on NestJS / Hono / tRPC? See the Utilization Cases — drop-in recipes for the most common backend frameworks.
Sponsors
If typia saves you time, please consider donating to the project .
References
- Inspired by
typescript-is - Source code: github.com/samchon/typiaÂ
- Benchmarks: benchmark/resultsÂ