JSON to TypeScript

Convert JSON objects to clean TypeScript interface definitions. Fast, free, and fully client-side.

Input source
Result / Output

How the JSON to TypeScript Works

Reads a JSON sample and writes TypeScript interface declarations that match its shape. Each nested object becomes its own named interface, and a root array becomes an exported Root type alias for its item type. A key missing from some sample objects is marked optional. Conversion runs in your browser and the JSON is never uploaded.

Usage Example

Pasting a sample REST response to get typed interfaces for a fetch call in a TypeScript front end.

Frequently Asked Questions

How are nested objects named?

Each nested object becomes an exported interface named after its JSON key with the first letter capitalized, so a key called address produces an Address interface. The root is named Root, or RootItem when the input is a top-level array.

When does a field become optional?

A field is required only when it appears in every sample object at that level. A field missing from some objects gets a question mark. Null values are typed as any, and values of conflicting types across items also fall back to any.

What does a top-level array produce?

Items are merged across the whole array into one item shape, which becomes an interface. The output then ends with export type Root as an array of that item type. Keys present in only some items are optional in the result.

Browse more

See all JSON tools.