Skip to content

JSON to io-ts - TypeScript Runtime Type Generator

Generate io-ts runtime type codecs from JSON data samples for functional TypeScript.

Input

json
loading editor…

Paste your JSON here...
or drop a file anywhere in this pane

Output

typescript

Generated codec will appear here...
press to generate codec

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 TypeOf to extract static types from your codecs, eliminating type duplication.

How to Use the io-ts Codec Generator Online

  1. Paste your JSON: Enter a sample JSON object or array that represents your data shape.
  2. Click Generate Codec: The tool produces t.type, t.string, t.number, t.boolean, and t.array codec definitions.
  3. 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