Skip to Content
Typia
Transform pure TypeScript types into
20,000x faster runtime validators, JSON serializers, and LLM schemas

Zero schema. Zero overhead. Just TypeScript.

Guide DocumentsPlaygroundGitHub

AOT Compilation Magic

Write TypeScript types as you normally would. At compile time, typia analyzes the AST and generates dedicated, optimized validation code.

Input

Your TypeScript Code

import typia, { tags } from "typia";

interface IMember {
  id: string & tags.Format<"uuid">;
  email: string & tags.Format<"email">;
  age: number &
    tags.Type<"uint32"> &
    tags.ExclusiveMinimum<19> &
    tags.Maximum<100>;
}

// just one line, with pure TypeScript type
const check: boolean = typia.is<IMember>(input);
β†’
↓
Output

Compiled Output

// compiled JavaScript β€” no schema overhead
((input) => {
  return (
    "object" === typeof input &&
    null !== input &&
    "string" === typeof input.id &&
    /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5].*$/.test(input.id) &&
    "string" === typeof input.email &&
    /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/.test(input.email) &&
    "number" === typeof input.age &&
    Number.isInteger(input.age) &&
    input.age >= 0 &&
    19 < input.age &&
    100 >= input.age
  );
})

Key Features

One library. Pure TypeScript types. Every runtime feature you need.

⚑

Super-fast Validation

typia.validate<T>(input)

20,000x faster (than class-validator)

AOT-compiled runtime validators outperform class-validator by 20,000x. Supports complex union types, recursive structures, and the most detailed error reporting.

Why AOT Compilation?

Traditional validators parse schemas at runtime. Typia generates dedicated validation code at compile time β€” the difference is measured in orders of magnitude.

Traditional Approach

βœ•

Define a separate schema object (Zod, io-ts, class-validator decorators)

βœ•

Schema is parsed and interpreted at every function call β€” runtime overhead

βœ•

TypeScript type and schema easily drift apart β€” double maintenance

βœ•

Complex union types and nested objects require verbose, manual handling

Typia β€” AOT Compilation

βœ“

Write pure TypeScript types β€” no schema DSL, no decorators, no duplication

βœ“

Compiler analyzes the type AST and emits optimized native code β€” zero runtime parsing

βœ“

Type and validator are always in sync β€” single source of truth

βœ“

Full support for unions, intersections, recursion, template literals, and tagged types

LLM Function Calling

Generate function calling schemas directly from TypeScript types.
Validation feedback boosts up LLM function calling success rates.

AI

LLM Integration

import { LlmJson } from "@typia/utils";
import typia, { tags } from "typia";

class ShoppingOrderController {
  /** some description comment for AI */
  create(input: IShoppingOrderCreate): void;
}

// Generate application
const app = typia.llm.application<ShoppingOrderController>();
const func = app.functions[0];

// Lenient parse + validation feedback
const data = func.parse(llmOutput);
const result = func.validate(data);
if (result.success === false)
  const feedback = LlmJson.stringify(result);

βœ…

Validation Feedback

Validate LLM output with typia.validate, then feed IValidation.IFailure back to the LLM for self-correction

πŸ”§

Lenient JSON Parsing

Recover from malformed JSON that LLMs frequently produce β€” broken quotes, trailing commas, missing brackets

πŸ”„

Type Coercion

Automatically cast LLM string responses to proper TypeScript types β€” "1" becomes number 1

πŸ“

Schema Generation

Generate function calling schemas directly from pure TypeScript types. No manual schema writing needed

Sponsors

Thanks for your support. Your donation encourages typia development.

Also, typia is re-distributing quarter of donations to nonara/ts-patch.

Sponsors
Last updated on