JSON to TypeScript

Generate TypeScript interfaces from a JSON payload, with named interfaces for nested objects.

Root interface name
JSON

A null value produces the null type, since there is no way to know the intended type from one sample.

TypeScript

How to Generate TypeScript from JSON

1

Paste an API response

Use a real response rather than a hand-written example. The types are inferred from the data you paste, so a realistic payload produces types that match production.

2

Name the root interface

Give it the name you would use in your code, such as User or OrderResponse. Nested objects get their own interfaces named after the field they came from.

3

Copy the interfaces

The result is ready to paste into a types file. Keys that are not valid identifiers are quoted, and arrays get element types rather than being left as any.

Features

Named interfaces for nested objects instead of inline types
Array element types inferred, with unions for mixed arrays
Keys that are not valid identifiers quoted automatically
Sensible interface names derived from field names
Empty arrays typed as unknown[] rather than any[]
Root interface name is yours to choose
Runs entirely in your browser, payloads are never uploaded
Free with no sign-up

Frequently Asked Questions

No. Everything runs in your browser, which matters because the fastest way to get good types is to paste a real API response, and those often contain customer data.

Because the sample had null in it and a single example cannot say what the type should be when it is not null. Change it to the real type, usually a union such as string or null.

An array containing more than one shape produces a union of the element types, so nothing is silently widened to any and you can see the inconsistency in your data.

Not from a single sample, because a field that is simply absent cannot be distinguished from one that is never sent. Add question marks yourself where the API documents a field as optional.

It emits interfaces, which are the usual choice for object shapes and can be extended and merged. Changing the keyword to type is a find and replace away if you prefer.

JSON has no date type, so an ISO timestamp is inferred as string, which is accurate. Convert to Date in your own code after parsing.

They come from the field names, with plural fields turned singular for array elements. Rename them freely; the generator is a starting point, not the final file.

Yes, completely free with no sign-up and no size limit.

Need a Custom Tool or Application?

We build production-grade web applications, SaaS platforms, and developer tools. Let's talk about your project.

or book a free call