HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
gcanti
io-ts
TypeScript2017–2022
gcanti / io-ts

io-ts

Runtime type system for IO decoding/encoding

40Distinct people
61Mentions
0Explicit recommenders
6.8KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Runtime type system for IO decoding/encoding

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 9–Nov 16 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/16/2026, 7:27:27 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year61 dated mentions

Observed mentions: 2017-04-12 02:46:33 UTC to 2022-09-23 18:51:02 UTC.

05101520252017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments20172018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 5 mentions; 0 submissions, 5 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 13 mentions; 1 submissions, 12 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 23 mentions; 0 submissions, 23 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 14 mentions; 1 submissions, 13 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2022

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC303
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC505
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC13112
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC23023
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC14113
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC303

From the project README

An excerpt from the repository, fetched Nov 13, 2026.

Read the project’s introduction
Installation Usage Stable features Experimental features (version 2.2+) Installation To install the stable version npm i io-ts fp-ts Note. fp-ts is a peer dependency for io-ts Usage Stable features Documentation of the main stable features (index.ts module) Experimental modules (version 2.2+) Experimental modules (*) are published in order to get early feedback from the community, see these tracking issues for further discussions and enhancements. The experimental modules are independent and backward-incompatible with stable ones. Decoder.ts module Encoder.ts module Codec.ts module Eq.ts module Schema.ts module (advanced feature) (*) A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.
Read the full README on GitHub

What Hacker News says

13 sources
Since you mentioned typescript first, here's a library that is basically an implementation of the ideas OP tries to convey: https://github.com/gcanti/io-ts Can't recommend using this library enough; being able to essentially reject any input (e.g. json over http) at runtime because it does not conform to the type definition is such an amazing thing!
In Parse, Don’t Validate
What I was most curious about was how they achieved run-time type checking in TypeScript. In this case, it was done by code generation using: https://github.com/bcherny/json-schema-to-typescript Personally, I'd prefer a way that doesn't involve another build step. A popular library I've often seen mentioned is io-ts: https://github.com/gcanti/io-ts One that I've taken a liking to, backed by ajv for JSON schema validation, is: https://github.com/andnp/ValidTyped
In Validating Data with JSON Schema, Angular and TypeScript
Not related to the new assert signatures feature (which is great!), but IMO the two best approaches to do what you want today are: - io-ts[1] This requires you to write your types as a runtime value, and allows you to extract static types from those, e.g.: const ContactInfo = t.type({ address_1: t.string, ... }) type ContactInfo = t.TypeOf<typeof ContactInfo> You can validate objects with `ContactInfo.decode(someObject)` Note that we can have the same name for the type and value because they live in different namespaces. When you do ContactInfo.decode, you're calling the decode property of `const ContactInfo`. When you use `ContactInfo` in a type position (e.g. `function x(arg: ContactInfo)`), you're using the `type ContactInfo` declaration - typescript-is[2] This uses TypeScript's transformer API. You can use
Read the rest
it with https://github.com/cevek/ttypescript. It generates validators for your interfaces/types/etc at compile-time. [1]: https://github.com/gcanti/io-ts [2]: https://github.com/woutervh-/typescript-is
In TypeScript 3.7: The Biggest Features and How to Use Them
I got interested in Reason last year after reading lorefnon's article [1] comparing Reason with TypeScript. Recently, after evaluating both for a large project we decided to prefer TypeScript primarily because TypeScript's support for intersection types, mapped types and conditional types is really awesome and make integration with javascript libraries a lot easier. As far as I could find, similar things can't be done in ReasonML at all (although I could be wrong on it). The tooling integration of TypeScript is also really awesome. Besides the usual refactoring, jump to definition support etc. a lot of effort has gone into small things that makes life easier. For example, if you have ctrl+click on a mapped type's property it will jump to the original type being mapped. In libraries like io-ts if you add doc comments on methods which are u
Read the rest
sed to derive the types, the documentation will be propagated to the derived types [2]. I recently found that the author of the above post has been experimenting [3] with babel-macros [4] to facilitate nice type-safe fluent APIs/abstractions which are compiled away to simple readable javascript with zero/negligible runtime overhead and found it a really neat idea. Looking at some of that code, it appears to be a lot simpler than writing ppx macros [5] for ocaml which I very briefly experimented with. [1] https://lorefnon.tech/2018/05/13/reasonml-vs-typescript-firs... [2] https://github.com/gcanti/io-ts/issues/201#issuecomment-4347... [3] https://github.com/ts-delight [4] https://github.com/kentcdodds/babel-plugin-macros [5] http://ocamllabs.io/doc/ppx.html
In TypeScript vs. ReasonML
> Eg in Typescript you will often still run into bugs caused by malformed JSON that doesn't fit the type declaration, badly or insufficiently typed third party libraries there's a fantastic typescript library, io-ts (https://github.com/gcanti/io-ts), that provides the ability to declare runtime types variables that you can infer compile time types from that solves exactly this problem. it's deifnitely work taking a close look at if you want to ensure type safety at runtime for data coming from third parties.
In Open-sourcing Sorbet: a fast, powerful type checker for Ruby

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.