JSON to TypeScript Interface

Infer TypeScript interfaces and type aliases from JSON sample data locally in the browser.

TypeScript settings

Input

Private by design: your data never leaves your device. Inferred types are a snapshot of the sample data.

A missing property is not the same as a present property with null.

Output

Paste valid JSON to generate TypeScript types.

Paste valid JSON to generate TypeScript types.

Good to know

The JSON to TypeScript interface generator derives TypeScript types directly in your browser from JSON sample data, as either an interface or a type alias, with T[] or Array<T> notation for arrays. Readonly properties and ReadonlyArray types, plus an export prefix, can each be enabled individually.

Typical searches include JSON to TypeScript interface, JSON to TypeScript, and create API types. A JSON Pointer such as /data/users deliberately selects a subtree, and optional properties can additionally be widened with undefined. Important: the types are derived from a snapshot of the sample data, and a missing property is not the same as a present property with null.

Typical use cases

Derive types from an API response for a frontend

Paste a sample API response to quickly get a matching TypeScript interface for frontend development.

Type only part of a large webhook payload

Use a JSON Pointer like /data/users to deliberately type only the relevant subtree of a large payload.

Tips for better results

Review missing vs. null properties for domain accuracy

Since a missing property is not the same as a present property with null, check for optional fields whether “optional with undefined” captures the right semantics.

Use multiple samples for more complete types

Since the types are only a snapshot of the sample data, test with several representative JSON samples to avoid missing rare fields and variants.

How it works

Step by step

  1. 1

    Paste a JSON sample

    Paste a representative JSON sample into the input field.

  2. 2

    Choose the declaration style and options

    Choose interface or type, array notation, readonly options, and the root name.

  3. 3

    Copy or download the TypeScript

    Copy the generated TypeScript code or download it as a file.

Features

Interface or type alias

Generate object types either as an interface or as a type alias.

Readonly and ReadonlyArray

Generate readonly properties and ReadonlyArray types for immutable data structures.

Local processing

Your data never leaves your device; type derivation runs entirely in the browser.

Frequently asked questions

Are the derived types always fully correct?

No. They are a snapshot of the sample data; optional fields and variants should be reviewed for domain accuracy.

Is my data uploaded?

No. Type derivation runs entirely locally in the browser.

More tools