Retour au classement

samchon/typia

TypeScripttypia.io

Super-fast/easy runtime validators and serializers via transformation

jsonstringifytypescriptfastajvcheckergeneratorruntimetransformvalidatortyperandom
Croissance des étoiles
Étoiles
5.9k
Forks
223
Croissance hebdomadaire
Issues
1
2k4k
avr. 2022sept. 2023févr. 2025juil. 2026
Artefactsnpmnpm install typia
README

Typia

Typia Logo

GitHub license NPM Version NPM Downloads Build Status Guide Documents Discord Badge

// RUNTIME VALIDATORS
export function is<T>(input: unknown): input is T; // returns boolean
export function assert<T>(input: unknown): T; // throws TypeGuardError
export function assertGuard<T>(input: unknown): asserts input is T;
export function validate<T>(input: unknown): IValidation<T>; // detailed

// JSON FUNCTIONS
export namespace json {
  export function schema<T>(): IJsonSchemaUnit<T>; // JSON schema
  export function assertParse<T>(input: string): T; // type safe parser
  export function assertStringify<T>(input: T): string; // safe and faster
}

// AI FUNCTION CALLING HARNESS
export namespace llm {
  // collection of function calling schemas + validators/parsers
  export function application<Class>(): ILlmApplication<Class>;
  export function structuredOutput<P>(): ILlmStructuredOutput;
  // lenient json parser + type coercion
  export function parse<T>(str: string): T;
}

// PROTOCOL BUFFER
export namespace protobuf {
  export function message<T>(): string; // Protocol Buffer message
  export function assertDecode<T>(buffer: Uint8Array): T; // safe decoder
  export function assertEncode<T>(input: T): Uint8Array; // safe encoder
}

// RANDOM GENERATOR
export function random<T>(g?: Partial<IRandomGenerator>): 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.

# 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<T>() 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.

//----
// examples/checkString.ts
//----
import typia, { tags } from "typia";
export const checkString = typia.createIs<string>();

//----
// examples/checkString.js
//----
import typia from "typia";
export const checkString = (() => {
  return (input) => "string" === typeof input;
})();

Sponsors

Backers

Thanks for your support.

Your donation encourages typia development.

Playground

You can experience how typia works by playground website:

Guide Documents

Check out the document in the website:

🏠 Home

📖 Features

🔗 Appendix

Inspired By

Dépôts similaires
fastapi/fastapi

FastAPI framework, high performance, easy to learn, fast to code, ready for production

PythonPyPIMIT Licensepythonjson
fastapi.tiangolo.com
100.8k9.7k
typicode/json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)

JavaScriptnpmMIT Licenseapifake
75.7k7.3k
redis/redis

For developers, who are building real-time data-driven applications, Redis is the preferred, fastest, and most feature-rich cache, data structure server, and document and vector query engine.

COtherdatabasekey-value
redis.io
75.6k24.7k
chinese-poetry/chinese-poetry

The most comprehensive database of Chinese poetry 🧶最全中华古诗词数据库, 唐宋两朝近一万四千古诗人, 接近5.5万首唐诗加26万宋诗. 两宋时期1564位词人,21050首词。

JavaScriptnpmMIT Licensejsonchinese
awesome-poetry.top
52.7k10.6k
prettier/prettier

Prettier is an opinionated code formatter.

JavaScriptnpmMIT Licenseformatterprinter
prettier.io
52.1k4.9k
nlohmann/json

JSON for Modern C++

C++MIT Licensejsonjson-pointer
json.nlohmann.me
50.2k7.4k
Asabeneh/30-Days-Of-JavaScript

30 days of JavaScript programming challenge is a step-by-step guide to learn JavaScript programming language in 30 days. This challenge may take more than 100 days, please just follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw

JavaScriptnpm30daysofjavascriptjavascript-for-everyone
46.6k10.5k
fastapi/full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.

TypeScriptnpmMIT Licensepythonjson
44.4k8.8k
AykutSarac/jsoncrack.com

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

TypeScriptnpmApache License 2.0jsontool
jsoncrack.com
44.3k3.6k
httpie/cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.

PythonPyPIBSD 3-Clause "New" or "Revised" Licensehttpcli
httpie.io
38.3k4k
SheetJS/sheetjs

📗 SheetJS Spreadsheet Data Toolkit -- New home https://git.sheetjs.com/SheetJS/sheetjs

Apache License 2.0xlsxexcel
sheetjs.com
36.3k7.9k
codex-team/editor.js

A block-style editor with clean JSON output

TypeScriptnpmApache License 2.0editorwysiwyg
editorjs.io
31.9k2.2k