+1
日增长
5,967
stars
235
forks
15
watchers
1,418
prs
1,088
issues
284
releases
README
Typia
!Typia Logo
typescript
// RUNTIME VALIDATORS
export function is(input: unknown): input is T; // returns boolean
export function assert(input: unknown): T; // throws TypeGuardError
export function assertGuard(input: unknown): asserts input is T;
export function validate(input: unknown): IValidation; // detailed
// JSON FUNCTIONS
export namespace json {
export function schema(): IJsonSchemaUnit; // JSON schema
export function assertParse(input: string): T; // type safe parser
export function assertStringify(input: T): string; // safe and faster
}
// AI FUNCTION CALLING HARNESS
export namespace llm {
// collection of function calling schemas + validators/parsers
export function application(): ILlmApplication;
export function structuredOutput(): ILlmStructuredOutput;
// typed questions for evaluation models + checked answer decoder
export function evaluation(): ILlmEvaluation;
// lenient json parser + type coercion
export function parse(str: string): T;
}
// PROTOCOL BUFFER
export namespace protobuf {
export function message(): string; // Protocol Buffer message
export function assertDecode(buffer: Uint8Array): T; // safe decoder
export function assertEncode(input: T): Uint8Array; // safe encoder
}
// RANDOM GENERATOR
export function random(g?: Partial): T;
typia is a transformer library supporting below features:
- Super-fast Runtime Validators
- Enhanced JSON schema and serde functions
- LLM function calling harness
- Protocol Buffer encoder and decoder
- Random data generator
[!NOTE]
- Only one line required, with pure TypeScript type
- Runtime validator is 20,000x faster than class-validator
- JSON serialization is 200x faster than class-transformer
- LLM function calling harness turns 6.75% → 100% accuracy
Write the type on the left, and typia compiles it into the validator on the right — at build time, with no schema and no runtime reflection.
!Write a TypeScript type and typia compiles it into a dedicated validator
Setup
Install typia with the ttsc toolchain.
bash
install
npm i typia
npm i -D ttsc typescript
build
npx ttsc
run a script directly
npx ttsx src/index.ts
You must use ttsc and ttsx. The stock tsc, ts-node, and tsx cannot apply the typia transform, so they will not work.
For bundler integration (Vite, Next.js, Webpack, Rollup, esbuild, ...), use @ttsc/unplugin.
Transformation
If you call typia function, it would be compiled like below.
This is the key concept of typia, transforming TypeScript type to a runtime function. The typia.is() function is transformed to a dedicated type checker by analyzing the target type T in the compilation level.
This feature enables developers to ensure type safety in their applications, leveraging TypeScript's static typing while also providing runtime validation. Instead of defining additional schemas, you can simply utilize the pure TypeScript type itself.
typescript
//----
// examples/checkString.ts
//----
import tyTop issues
#447[Discussion] who is using `typia` in production?6 comments · 2022-12-23#2518JSON Schema support is incredibly poorly documented1 comments · 2026-10-26
Discussions
#1867@typia/mcp forces JSON.stringify on return values — how to return plain text?3 comments · 2026-05-24#1697Wrong type of `examples`?2 comments · 2025-11-28#1668Pronunciation of typia1 comments · 2025-09-17#1664Potential solution for ts-go future2 comments · 2025-09-04#1614How to specify combinations of properties on an object1 comments · 2025-07-23#1613How to check that an object has one non-empty property?1 comments · 2025-07-23#1608Runtime type introspection?2 comments · 2025-07-19#1607Tagging of properties, retrievable at runtime1 comments · 2025-07-15
Latest release
v15.4.1 v15.4.1 2026-11-14 🐞 Bug Fixes - native: Publish files typia did not change as their authored text - by @samchon and Claude Opus 5.5 in https://github.com/samchon/typia/issues/2558 (fd886) View changes on GitHub