API Reference

io-ts

Runtime type validation for TypeScript using codecs that provide both a decoder and a static type.

Official Documentation ↗
CompatibilityThis documentation covers version v2.2. Check the official docs for the latest API surface.

Installation

npmnpm install io-ts

Methods

io-ts codecs decode unknown input into validated values or a detailed error list, keeping types honest.

Key Features

  • Codecs combine runtime checks and static types
  • Composable, supports recursion
  • Pairs with fp-ts for functional flows

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

FAQ

How is io-ts different from a schema library?
It models validation as an algebraic type using Either, so failures compose without exceptions and pair naturally with fp-ts.
Why does decode return Either?
Either makes the failure explicit and forces callers to handle the error branch instead of swallowing an exception.
Does it support recursive types?
Yes, with t.recursion. Declare the codec with an explicit type annotation so recursion can be referenced.