Skip to content
I Hate Online Tools

JSON to TypeScript

Infer TypeScript interfaces from a JSON sample.

Runs in this tab. The file stays here.

TypeScript

This runs in your browser. Nothing is uploaded.

About JSON to TypeScript

Infer TypeScript interfaces from a JSON sample in the browser — best-effort types you should refine.

Paste a JSON payload, get a starting TypeScript interface tree. Nested objects become named interfaces when possible. Unions, optional fields, and 'this key is sometimes null' still need human judgment — inference from one sample cannot see every shape your API returns.

This is a kickstart for types, not a replacement for OpenAPI or a hand-maintained zod schema. Pretty-print or validate JSON first with the JSON formatter if the paste is messy.

curl-to-fetch helps turn a captured request into fetch() code. JSON↔CSV is for tabular conversion. Neither writes TypeScript interfaces.

How to use JSON to TypeScript

  1. 1Paste a representative JSON sample.
  2. 2Generate TypeScript interfaces.
  3. 3Copy and refine types for optionals and unions.

What it won't do

  • Best-effort inference from one sample.
  • Not a full OpenAPI or runtime validator generator.

Common questions

Are nested objects supported?

Yes — nested structures are emitted as related interfaces when inference can name them cleanly.

Will it detect every optional field?

No. One sample cannot prove absence. Mark optionals yourself after comparing real payloads.

Does JSON leave my browser?

No. Inference runs locally.

Related tools

Why this one doesn't upload your file

There is no server to upload to. This page is a static file, and the work happens in your browser using the same graphics and WebAssembly code that renders every other site you visit. Your file is read from disk into memory, processed, and handed back as a download. Once the page has loaded you can disconnect from the network entirely and it keeps working. The longer explanation

Install the app