Standard Schema for TypeBox

Read and write projections from one schema: derive input and output shapes, validate forms with coercion and field-level errors, and plug into any Standard Schema consumer.

bun add typebox-standard-schema
# or
npm install typebox-standard-schema
import { Type, validate } from 'typebox-standard-schema'

const User = Type.Object({
  id: Type.Readonly(Type.String()),
  email: Type.String({ format: 'email' }),
  password: Type.Writeonly(Type.String({ minLength: 8 })),
})

const CreateUser = Type.Write(User) // { email, password }
const PublicUser = Type.Read(User) // { id, email }

// validate the input, or hand `User` to any Standard Schema consumer
const result = validate(User, { email: 'a@b.c', password: 'secret123' })

Standard Schema out of the box

Every schema built via Type carries ~standard, so it plugs into tRPC, Hono, Elysia, TanStack Form, React Hook Form and SvelteKit remote functions, fully typed.

Read/write projections

Mark fields with Type.Readonly and Type.Writeonly, then derive input and output shapes, runtime and static types, with Type.Write and Type.Read.

JSON Schema and OpenAPI

Standard JSON Schema built in: draft 2020-12, draft-07 or OpenAPI 3.0 for docs generators, AI SDK tools and MCP servers, no converter needed.

Validation that fits forms

Coercion of form and query strings, defaults, PATCH-safe partial schemas and flat issues with a path per field. Your input is never mutated.