What Is io-ts?
io-ts is a TypeScript library for runtime type validation using composable codecs that can decode, encode, and validate data at runtime. It follows functional programming principles and integrates tightly with fp-ts for powerful data pipelines.
This is used for:
- API Boundary Validation: Decode external data at the I/O boundary of your application with guaranteed type safety.
- Data Migration: Validate legacy data dumps by running them through io-ts codecs generated from your current schema.
- TypeScript Type Derivation: Use
TypeOfto extract static types from your codecs, eliminating type duplication.
How to Use the io-ts Codec Generator Online
- Paste your JSON: Enter a sample JSON object or array that represents your data shape.
- Click Generate Codec: The tool produces
t.type,t.string,t.number,t.boolean, andt.arraycodec definitions. - Copy into your project: Use
codec.decode(data)to validate and type-cast incoming data.
Frequently Asked Questions
Can I use these codecs without fp-ts?
Yes. io-ts can be used standalone. The generated codecs work with fold from fp-ts for error handling, but you can also use Either.isLeft for simpler checks without the full fp-ts ecosystem.
Is this tool safe?
Yes. All processing happens 100% client-side in your browser. Nothing is uploaded to any server.
Is this tool free?
Yes, completely free with no usage limits or registration required.
Real-World Examples
A functional TypeScript API gateway can use io-ts codecs generated from this tool to validate every incoming request payload. When the upstream API changes its response shape, developers paste a new sample and regenerate the codec, keeping the gateway's validation layer always in sync.
Related Tools
- JSON to Valibot — Generate modular Valibot validation schemas from JSON samples.
- JSON to Zod Schema — Build Zod validation schemas with type inference from JSON data.
- JSON to Type Guard — Create TypeScript type guard functions from sample JSON.