whatisgithub

What is io-ts?

gcanti/io-ts — explained in plain English

Analysis updated 2026-06-24

6,814TypeScriptAudience · developerComplexity · 2/5Setup · moderate

In one sentence

A TypeScript library that validates real data at runtime against types you define in code, returning precise field-level error descriptions when something doesn't match instead of throwing vague exceptions.

Mindmap

mindmap
  root((io-ts))
    What it does
      Runtime validation
      Precise error messages
      Decode to typed values
    Tech stack
      TypeScript
      fp-ts
    Use cases
      Validate API responses
      Parse config files
      Decode form input
    Key concepts
      Codecs
      Either type
      Explicit error values
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Validate API responses at runtime to confirm they match your TypeScript types before using the data

USE CASE 2

Decode user-submitted form data and get a clear list of exactly which fields are invalid and why

USE CASE 3

Parse config files at startup and fail fast with precise error messages if any field is missing or has the wrong type

What is it built with?

TypeScriptfp-ts

How does it compare?

gcanti/io-tsbuildship-ai/rowyritwickdey/vscode-live-server
Stars6,8146,8126,819
LanguageTypeScriptTypeScriptTypeScript
Setup difficultymoderatehardeasy
Complexity2/53/51/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires fp-ts installed as a peer dependency alongside io-ts.

So what is it?

io-ts is a TypeScript library that lets you validate data at the moment your program receives it, not just while writing the code. TypeScript adds type annotations to JavaScript, but those checks only happen during development and disappear when the code actually runs. When your program fetches data from an API or reads a file, TypeScript has no way to confirm that what arrived matches what you expected. io-ts solves that gap by letting you define types that can actively inspect and validate real data at runtime. When validation passes, io-ts can decode the raw data into a typed value your program can use safely. When it fails, it returns a description of what went wrong rather than throwing a vague error. This makes it easier to trace exactly which field or value did not match the expected shape. The library has a required peer dependency called fp-ts, which is another library by the same author that brings functional programming patterns to TypeScript. You install both together. Functional programming here means that operations like decoding return explicit success or failure values rather than relying on exceptions, which makes error handling more predictable. The README is brief and mostly points to separate documentation files for specific modules. The stable API is documented in an index file. There is also a set of experimental modules introduced in version 2.2, covering Decoder, Encoder, Codec, Eq, and Schema functionality. These experimental modules are flagged as independent from the stable API and may change without notice. The README does not include worked examples or a getting-started walkthrough. It is a short pointer document aimed at developers who already know what runtime type validation is and are looking for installation steps and module references.

Copy-paste prompts

Prompt 1
Given this TypeScript interface, write an io-ts codec that validates the same shape at runtime and show how to decode an API response using it
Prompt 2
I'm getting an io-ts decode error. Here is the error output and my codec definition, tell me what input shape was expected and what was actually wrong with the data
Prompt 3
Convert this JSON response from my API into an io-ts codec, then show me how to handle success and failure using fp-ts Either
Prompt 4
Write an io-ts codec for a user object with name, email, and optional age, then show how to decode an array of users from an API call

Frequently asked questions

What is io-ts?

A TypeScript library that validates real data at runtime against types you define in code, returning precise field-level error descriptions when something doesn't match instead of throwing vague exceptions.

What language is io-ts written in?

Mainly TypeScript. The stack also includes TypeScript, fp-ts.

How hard is io-ts to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is io-ts for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.