Skip to Content
📖 Guide Documents🙋🏻‍♂️ Introduction

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 — on the left is the source you write, on the right is what typia generates for you at compile time:

Write a TypeScript type and typia compiles it into a dedicated validator

No reflection at runtime, no schema file to maintain — just the exact comparisons your IMember 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 Output” is produced by typia’s compile-time transform — stock tsc will not produce it. To enable the transform, install the TypeScript 7 toolchain in Setup and build with ttsc, ttsx, or @ttsc/unplugin. Without setup, your typia.is<T>() call sites throw at runtime instead.

Typia Logo

MIT LicenseNPM VersionNPM DownloadsBuild StatusGurubaseDiscord

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 faster assertStringify, 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 + .proto text 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 T

Only one line required, with pure TypeScript types

Runtime validator up to 20,000× faster than class-validator (benchmark )

JSON serialization up to 200× faster than class-transformer (benchmark )

LLM function calling success rate: 6.75% → 100% with the typia harness (story )

Build setup


The transformation above happens at compile time, so typia needs to be wired into the TypeScript build. Use ttsc for TypeScript 7 builds, ttsx when running a TypeScript entrypoint directly, and @ttsc/unplugin for bundlers such as Vite, Next.js, Webpack, esbuild, Rollup, and Bun.

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

Sponsors

Backers

If typia saves you time, please consider donating to the project .

References

Last updated on