Report

Help us improve this tool

JSON To Io TS

Generate io-ts runtime validators and TypeScript codecs from JSON sample data in the browser.

O M T

Generate io-ts codecs from JSON payloads

The io-ts library lets TypeScript teams validate unknown JSON at runtime using codecs that mirror static types. Building those codecs by hand for nested API responses takes time and drifts quickly when payloads change. This generator inspects your JSON sample and emits io-ts codec definitions you can paste into a TypeScript project.

What this tool does

Paste JSON in the input panel. The converter walks nested objects and arrays, infers primitive and composite shapes, and outputs io-ts t.type definitions with supporting nested codecs. You can customize the root codec name to match your domain model before copying the result.

Common use cases

  • Bootstrap runtime validators for REST or webhook payloads.
  • Create starter codecs before wiring decode pipelines in services.
  • Document expected payload shapes for frontend and backend teams.
  • Compare inferred codecs against JSON Schema or OpenAPI contracts.

Related tools

Need static TypeScript interfaces instead of runtime codecs? Try the JSON to TypeScript POJO Generator or JSON Schema to Zod. For GraphQL schema drafts from JSON, use the JSON to GraphQL tool.

Frequently Asked Questions

Does my JSON leave the browser?

No. Conversion runs entirely in your browser. Your JSON is never uploaded to a server, which makes the tool safe for internal API samples and production-like fixtures.

Do I need to install io-ts in my project?

Yes. The generated output imports io-ts. Install it in your project with your package manager, then paste the codecs into a TypeScript file and wire them into your decode or validation flow.

Can I rename the root codec?

Yes. Use the Root Codec Name field to control the exported root constant name. Nested helper codecs keep generated names based on object keys in your JSON sample.

Are optional fields supported?

The generator reflects the exact keys present in your JSON sample. Fields missing from the sample are not marked optional automatically. Add t.partial or union types manually after generation when you need optional properties.

How is this different from JSON Schema to Zod?

Both tools help with runtime validation. This converter targets the io-ts codec style used in functional TypeScript codebases, while the JSON Schema to Zod tool emits Zod schemas from JSON Schema documents instead of raw JSON samples.