Developer

JSON to TypeScript

Turn a JSON object into typed TypeScript interfaces.

  • Instant
  • Free
  • Private (processed locally)
  • No sign-up

TypeScript interfaces

Type an API response in seconds

Rather than hand-writing the interfaces matching a big JSON, paste it here. The tool infers types recursively: nested objects turned into separate interfaces, typed arrays, optional fields marked with a “?”.

  1. Paste the JSON

    An API response, a config file, any object.

  2. Name the root

    “Root” by default, or the name of your choice.

  3. Copy the interfaces

    Ready to paste into your .ts file.

Inference example

JSON valueInferred type
"name": "Ada"name: string
"age": 36age: number
"roles": ["admin"]roles: string[]
"profile": { … }profile: Profile
(key missing from one array object)field?: type

Inference from one example: remember to refine nulls (often into a string | null union) and check the types afterwards. Everything happens locally, your JSON never leaves the browser.

Frequently asked questions

How are the types inferred?

The tool examines each value: a number becomes number, a string string, a boolean boolean. Objects become interfaces named after their key, and arrays are typed by their elements (string[], MyType[]…).

How are optional fields detected?

When an array contains several objects, the tool merges their keys. A key present in some objects but not all is marked optional with “?”. That is exactly the expected behaviour for heterogeneous API data.

What happens with null values or empty arrays?

A null value is typed null (to refine manually, often into a union like string | null). An empty array becomes unknown[], because its element type can’t be determined from a single example.

Is the result ready to paste into my code?

Yes: the root interface is named to your choice (“Root” by default), sub-interfaces are declared above, and the syntax is valid TypeScript. Rename the interfaces to your domain for clarity.