JSON to TypeScript Interface
Generator
Paste your JSON and instantly get typed TypeScript interfaces. Handles nested objects, arrays, and all primitive types. No signup, no server — runs entirely in your browser.
Open JSON to TypeScript GeneratorStop writing interfaces by hand
Instant Types
Paste any JSON object and get a fully typed TypeScript interface in one click — no manual work.
Nested Interfaces
Nested objects are automatically extracted into separate named interfaces so your types stay clean.
100% Private
Your JSON never leaves your device. There is no backend — everything runs locally in the browser.
Everything you need for JSON to TypeScript
export interface declarations ready to paste into your TypeScript project.
Type[]. Array items that are objects get their own named interface.
.ts file.
Related JSON tools
Common questions answered
Is JSON to TypeScript conversion free?
Yes, free with no account needed.
Does JSON to TypeScript conversion send data online?
No. All conversion runs locally in your browser.
What TypeScript types does it generate?
It generates interface definitions with typed properties: string, number, boolean, null, arrays, and nested interfaces.
Can it handle nested JSON objects?
Yes. Nested objects generate nested TypeScript interfaces with descriptive names derived from the key names.
Does it handle arrays of objects?
Yes. Arrays of objects generate a typed array with an inferred interface for the items.
What are TypeScript interfaces?
TypeScript interfaces define the shape of an object — specifying which properties exist, their types, and whether they are required. Generating interfaces from JSON gives you autocompletion, compile-time error checking, and documentation directly in your IDE. This eliminates runtime bugs caused by accessing non-existent properties or passing wrong types.
This tool analyzes your JSON and generates TypeScript interface definitions. Nested objects produce nested interfaces, arrays infer their element type, and primitives map to string, number, boolean, or null. When array elements have different shapes, the generator creates a union type. The output is ready to paste into a .ts file.
{
"id": 1,
"name": "Alice",
"email": "alice@test.com",
"roles": ["admin"],
"address": {
"city": "Portland",
"zip": "97201"
}
}
interface Root {
id: number;
name: string;
email: string;
roles: string[];
address: Address;
}
interface Address {
city: string;
zip: string;
}
Get the most out of this tool
- Generate interfaces from real API responses rather than documentation — actual data often has undocumented fields.
- Review generated interfaces for optional fields: if a field could be absent, add ? manually.
- Use the interfaces with fetch calls: fetch<User>("/api/user") gives typed API responses throughout your codebase.
Ready to generate TypeScript interfaces?
Free forever. No signup. Instant results.
Generate TypeScript interfaces nowTypeScript interfaces from JSON explained
TypeScript is a strongly-typed superset of JavaScript that adds compile-time type checking. When you fetch JSON data from an API or read it from a file, TypeScript cannot automatically infer the type — you get any by default, which defeats the purpose of using TypeScript. To get proper type checking, you must define an interface or type alias that describes the shape of the JSON. Manually writing these definitions for large API responses is tedious and error-prone; this tool automates the entire process.
The converter analyzes the JSON structure recursively and generates TypeScript interface declarations. Each JSON object becomes an interface with typed properties. JSON strings map to string, numbers to number, booleans to boolean, null to null, and undefined to undefined. Arrays of objects generate interfaces for the element type and use Array<ElementType> or ElementType[] syntax. Nested objects generate nested interfaces, with each getting a descriptive name derived from its parent key.
Type unions are generated for JSON values that could be one of several types. If a field is sometimes a string and sometimes null, the converter generates string | null for that property. If an array contains mixed element types (both numbers and strings), the converter generates Array<string | number>. These union types accurately reflect the real shape of the data and prevent incorrect assumptions in your code.
Optional properties in TypeScript are marked with a question mark (property?: type). The converter adds the optional modifier when a JSON key is absent from some elements of an array of objects but present in others — this is a common pattern where some API response records have fields that others lack. Getting this right automatically saves significant debugging time compared to marking everything required.
TypeScript interfaces are structural, not nominal. This means any object that has the required properties with the right types satisfies the interface, even without explicitly declaring that it implements it. This makes generated interfaces immediately usable with fetch responses, Axios response data, and JSON.parse() results once cast to the interface type. You can also use them with TypeScript's Partial<T>, Readonly<T>, and Pick<T, K> utility types.
Teams maintaining large TypeScript codebases often keep generated type files alongside their API client code. When an API version changes, developers paste the new sample response into this converter, compare the output to the existing interface definitions, and update accordingly. Some teams automate this with JSON Schema-to-TypeScript generators for complex schemas, but for common REST API response shapes, this tool is the fastest starting point.
When developers use this tool
Additional frequently asked questions
Should I use interface or type alias for generated definitions?
Both work for describing JSON shapes. Interfaces are preferred when you might extend the type later using extends. Type aliases are needed for unions and intersections. For pure JSON object shapes, interface is the conventional choice and what this converter generates by default.
How do I use the generated interface with fetch?
Cast the parsed response: const data = await response.json() as MyInterface. This tells TypeScript to treat the value as the specified type. For strict type safety, validate at runtime using a schema validator like Zod or io-ts before casting, since fetch returns any.
Can the generated interfaces handle recursive or circular JSON structures?
Truly recursive JSON (where a type references itself) cannot be represented by simple inference from a single JSON sample. The converter generates flat interfaces for the sample depth provided. For recursive structures like tree nodes, manually add a self-referencing property after generation: children?: TreeNode[].
What is the difference between interface and Zod schema?
A TypeScript interface is a compile-time type annotation that disappears at runtime. A Zod schema is runtime validation code that also infers TypeScript types. Use interfaces when you trust the data source; use Zod when you need to validate untrusted input like user-submitted JSON or external API responses.