TypeBox is a runtime type system that constructs JSON Schema objects from TypeScript-like type definitions, automatically inferring static TypeScript types via Type.Static. The current stable version is 1.1.36, with frequent releases following semantic versioning. It differentiates itself by providing a unified type system that works both at compile time (TypeScript type checking) and runtime (JSON Schema validation), making it ideal for API validation, data serialization, and building type-safe protocols. Unlike standalone validators like Ajv or Zod, TypeBox focuses exclusively on schema generation and type inference, leaving validation to JSON Schema validators.
npm install typeboxNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to define an object schema with TypeBox, infer the TypeScript type using Type.Static, and validate data with Ajv.
Use Type.Static<typeof schema> as a type annotation, not a runtime value.
Always use parentheses: Type.String(), not Type.String.
Use Type.Object({ key: Type.String() }) instead of Type.Object({ key: { type: 'string' } }).Ensure you have the correct import: import Type from 'typebox'. If you see this in a type annotation, you might have a naming conflict.
Call Type.String() with parentheses, even if no arguments: Type.String().
Ensure the argument to Type.Static is a schema built with TypeBox builders: Type.Static<typeof mySchema> where mySchema is constructed via Type.*.
No dependency data recorded yet.