Repolode
samchon

samchon/typia

TypeScript transformer that compiles pure TypeScript types into runtime validators, JSON serializers, protobuf codecs and random generators.

Open-source alternative to:class-validator

Stars
5,962
Forks
233
Open issues
5
Last commit
21 hours ago

What is it?

typia turns TypeScript types into runtime functions at build time. You write a type such as typia.is<T>() or typia.assert<T>(), and the transformer analyzes T during compilation and emits a dedicated checker, so no separate schema definition or runtime reflection is needed.

The library covers several areas: runtime validators (is, assert, validate), an enhanced JSON layer with schema generation and faster stringify and parse functions, Protocol Buffer message generation with encode and decode, and a random data generator. It also includes an LLM function-calling module that builds tool schemas from class types and validates or parses model output.

Typia requires the ttsc toolchain instead of plain tsc, ts-node or tsx, because the stock tools do not apply the transform. Bundler integration is available through @ttsc/unplugin for Vite, Next.js, Webpack, Rollup and esbuild.

Key features

  • 01Generates type checkers from pure TypeScript types at build time, with no schema files.
  • 02Provides is, assert and validate functions for runtime validation.
  • 03Generates JSON Schema and offers type-safe stringify and parse functions.
  • 04Encodes and decodes Protocol Buffer messages from TypeScript types.
  • 05Builds function-calling schemas for LLM tools and validates model output.
  • 06Includes a random data generator driven by TypeScript types.

Use cases

  • Validating API request bodies in a TypeScript backend without writing separate schemas.
  • Producing fast JSON serialization for known types.
  • Building tool definitions for LLM function calling from TypeScript classes.
  • Generating test fixtures from existing types.

Quick start

  1. 1

    Install typia and the ttsc/typescript toolchain

    npm i typia npm i -D ttsc typescript
  2. 2

    Build the project with ttsc (stock tsc will not apply the transform)

    npx ttsc
  3. 3

    Run a script directly with ttsx

    npx ttsx src/index.ts

Things to know

  • Requires the ttsc toolchain; stock tsc, ts-node and tsx cannot apply the transform.
  • Bundler use needs the separate @ttsc/unplugin package.

In collections

Topics

FAQ

What is typia?
TypeScript transformer that compiles pure TypeScript types into runtime validators, JSON serializers, protobuf codecs and random generators. typia turns TypeScript types into runtime functions at build time. You write a type such as typia.is<T>() or typia.assert<T>(), and the transformer analyzes T during compilation and emits a dedicated checker, so no separate schema definition or runtime reflection is needed.
Is typia free to use? What license does it have?
typia is open source under the MIT license. Check the license terms before using it in commercial products.
Is typia still maintained?
Actively maintained. The last commit to typia was on Nov 6, 2026.
What can I use typia for?
Validating API request bodies in a TypeScript backend without writing separate schemas. Producing fast JSON serialization for known types. Building tool definitions for LLM function calling from TypeScript classes. Generating test fixtures from existing types.
How do I install typia?
Install typia and the ttsc/typescript toolchain: npm i typia npm i -D ttsc typescript Build the project with ttsc (stock tsc will not apply the transform): npx ttsc Run a script directly with ttsx: npx ttsx src/index.ts
Where can I get typia?
The source code and installation instructions are on GitHub: https://github.com/samchon/typia

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects