Typia turns pure TypeScript types into fast runtime validators, JSON helpers, Protocol Buffer codecs, and LLM function-calling harnesses at build time.
Overview
Typia is a TypeScript transformer library that generates specialized runtime code from your types instead of interpreting schemas on each call. You write ordinary interfaces and call typia functions; the compiler rewrites those calls into dedicated validators and serializers.
Core capabilities include assert, is, validate, and shallow checks, JSON stringify and parse helpers with schema generation, Protocol Buffer encode and decode without separate `.proto` files, and random data generation that respects tags and constraints. Documentation highlights large speedups over decorator-based validators and class-based serializers in published benchmarks.
A major recent focus is LLM function calling: typia can build application schemas from TypeScript types, parse lenient JSON from models, coerce types, and return validation feedback for self-correction workflows. Integration notes cover NestJS, tRPC, Hono, LangChain, Vercel AI SDK, and MCP-related setups.
Installation relies on the ttsc toolchain or unplugin integrations for Vite, Next.js, Webpack, Rollup, and esbuild because stock `tsc` and `tsx` cannot apply the transform. A playground site lets you compare input types with compiled output interactively.
Key features
- AOT runtime validators from types
- JSON schema and stringify helpers
- Protocol Buffer encode and decode
- LLM function calling harness
- Random mock data generation
- Lenient JSON parsing for LLM output
- Bundler unplugin integrations
- Pure TypeScript without schema DSL
Use cases
- Validating API payloads with TypeScript types
- Speeding JSON serialization hot paths
- Generating OpenAPI schemas from types
- Hardening LLM tool-calling pipelines
- Creating protobuf messages without proto files