export interface Root { user: User; posts: Post[]; meta: Meta; } export interface Meta { total: number; page: number; perPage: number; } export interface Post { id: number; title: string; published: boolean; views: number; author: null; } export interface User { id: number; name: string; email: string; role: string; active: boolean; score: number; tags: string[]; address: Address; } export interface Address { street: string; city: string; zip: string; country: string; }
JSON to TypeScript Interface Generator — Convert JSON to TS Types Online Free
What's included
Features
? to every property for partial types, partial update payloads, or APIs that may omit fieldsnull, unknown, and any for null JSON values to match your tsconfig and safety requirementsT[] (concise, idiomatic) or Array<T> (explicit, readable in complex generics)Root to ApiResponse, UserProfile, or whatever matches your domain model.ts file — drop directly into your types/ folder; pair with the JSON Table Viewer to inspect the actual data while typing against your new interfacesAbout this tool
Generate TypeScript Interfaces from JSON Instantly — No Install, No Sign-Up
You just got an API response back and now you need to write TypeScript interfaces for it. If it has five nested objects and three arrays, that is twenty minutes of tedious typing — and you have to get every field name exactly right or your code won't compile. Paste the JSON here and get the interfaces in two seconds.
The generator walks your entire JSON tree recursively. Every nested object becomes its own named interface. Arrays of objects get a unified interface covering all keys that appear across every element. Property types are inferred directly from the values: string, number, boolean, null, and arrays — with union types for mixed arrays.
Two output modes give you control over TypeScript style. interface is the traditional choice for describing object shapes and is open for extension through declaration merging. type (type alias) is stricter by default and works better for mapped and conditional types. For plain API response shapes both are functionally identical — pick the style your codebase uses.
The null as setting matters for correctness. When a JSON value is null, TypeScript needs a type. Setting it to null (the default) is the most accurate representation and works with strictNullChecks. Setting it to unknown is the safest choice for untrusted API data — TypeScript will force you to check the value before using it. Setting it to any skips type checking entirely, which is the least safe but most permissive option.
All conversion runs entirely in your browser — no server, no sign-up, works offline. Paste your JSON, adjust the options to match your codebase conventions, and download the .ts file.
Step by step
How to Use
- 1Paste your JSON into the left panelPaste any JSON object or array into the left input panel. TypeScript interfaces appear instantly in the right panel as you type — no button press required. Click Sample to load a realistic example with nested objects, arrays, and null values to see all the generated interfaces.
- 2Set the root interface nameChange the Root name field in the header to whatever your top-level type should be called —
ApiResponse,UserPayload,OrderData. Nested object keys derive their own names automatically: a"user"key becomesUser,"shippingAddress"becomesShippingAddress,"posts"array items becomePost. - 3Choose interface or type alias outputClick interface to generate
interface Root {}declarations (open for extension via declaration merging). Click type to generatetype Root = {}aliases (closed by default, more flexible for unions and mapped types). For plain API response shapes both are functionally identical — pick your codebase's preferred style. - 4Control array syntax and null handlingToggle between
T[](concise, idiomatic) andArray<T>(explicit, useful in complex generics) for array types. Use the null as control for null JSON values:null(most precise, requiresstrictNullChecks),unknown(safest for untrusted external data), orany(disables type checking for that property). - 5Enable optional fields or export keywordToggle optional to add
?to every property (name?: string) — use for partial update types or APIs that may omit fields. Toggle export to add theexportkeyword to every interface (on by default) so they can be imported anywhere in your project. - 6Copy to clipboard or download the .ts fileClick Copy in the output panel header to copy all generated interfaces to your clipboard. Click Download .ts to save the file directly to disk. Drop it into your project's
types/folder and import the interfaces wherever you need type-safe access to the API data.
Real-world uses
Common Use Cases
types/ folder. You'll have a complete, accurate type layer in minutes rather than hours.unknown as the null-as setting for untrusted external data, which forces explicit type checks in your code before accessing nullable fields.Got questions?
Frequently Asked Questions
Paste your JSON into the left input panel — TypeScript interfaces appear instantly in the right panel. Click Copy or Download .ts to use the output.
JSON strings → string, numbers → number, booleans → boolean, null → null / unknown / any (your choice), arrays → T[] or union types, nested objects → separate named interfaces.
Each nested object generates its own interface. The name is derived from the JSON key in PascalCase — "userAddress" becomes UserAddress. Parent interfaces reference child interfaces by name.
Arrays of objects are merged — all items are combined into one interface covering every key across all elements. The interface name is singularized from the array key (users → User, posts → Post).
interface supports declaration merging (useful for library types). type is closed by default and more flexible for unions and mapped types. For plain object shapes from JSON, both are functionally identical — pick whichever your codebase uses.
It adds ? to every property (key?: type), making all fields optional. Use it for partial update types or APIs where fields may be absent.
null is the most precise type and works with strictNullChecks in tsconfig. unknown is the safest choice for untrusted external data — TypeScript forces you to check the value before using it. any skips type checking entirely.
Yes. If your JSON is an array like [{...}, {...}], the tool generates an interface for the element type using the singularized root name. The root type is Root[] (or whatever you named it).
Yes. Download the .ts file and drop it into your types/ folder. With the export toggle on (default), all interfaces are exported and can be imported anywhere in your project.
Completely free, no sign-up. All conversion runs in your browser — no data is sent to any server. You can safely paste sensitive API responses or private data structures.