TypeBox

Json Schema Type Builder with Static Type Resolution for TypeScript



License

About This Fork

This is the @alkdev/typebox fork — a community-maintained LTS branch of TypeBox 0.x. The original TypeBox project has been rewritten as 1.x with breaking changes; this fork continues the 0.x API that many projects depend on, with minimal maintenance overhead since the feature set is essentially complete.

  • Supply chain security: Published from our own infrastructure; no dependency on upstream publish access.
  • Stability: No breaking rewrites planned. Bug fixes and compatibility patches only.
  • Drop-in replacement: @alkdev/typebox is API-compatible with @sinclair/typebox 0.x.

Overview

TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.

This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.

Install

$ npm install @alkdev/typebox

See Installation →

Quick Start

import { Type, type Static } from "@alkdev/typebox";

const T = Type.Object({
  x: Type.Number(),
  y: Type.Number(),
  z: Type.Number(),
});

type T = Static<typeof T>;

See Usage →

Documentation

Types

Values

Syntax

Type System

Other

License

MIT

Description
No description provided
Readme 2.1 MiB
Languages
TypeScript 99.8%
JavaScript 0.2%