JSON to TypeScript

Generate TypeScript interfaces from any JSON. Handles nested objects, arrays, and union types.

Paste JSON to generate TypeScript interfaces
Root name
JSON Input
TypeScript Output

Frequently asked questions

What is a TypeScript interface?
A TypeScript interface defines the shape of an object — which fields it has and what types they are. It lets TypeScript catch type mismatches at compile time, so you get errors in your editor before your code runs. Interfaces are erased at runtime and produce no JavaScript output.
Why generate interfaces from JSON?
When working with an API response, you need to manually write interfaces that match the JSON shape. For large or deeply nested responses this is tedious and error-prone. Generating them automatically from a sample response is faster and more accurate.
What does 'mark nulls as optional' mean?
When a field is null in the sample JSON, it could mean the field is optional (sometimes absent) or always present but nullable. Enabling this option generates field?: type instead of field: null, which is usually more useful when the field can be missing entirely.
How are arrays handled?
If an array contains objects, the generator creates a separate interface for the array item type and references it. For example, tags: [{id: 1}] becomes tags: Tag[] with a separate Tag interface. Empty arrays become unknown[] since the item type cannot be inferred.