How to use the JSON to TypeScript Interface
Generate TypeScript interfaces in one step:
Paste your JSON
Paste a JSON object (or array of objects) into the input. The generator uses the structure and value types to infer TypeScript types.
Set the root interface name
Choose the name for the root interface (default: 'RootObject'). Nested objects get their own named interfaces automatically.
Click Generate
The TypeScript output appears with properly typed interfaces. Arrays become typed arrays (string[], number[], NestedType[]).
Copy into your project
Copy the generated interfaces directly into your .ts or .d.ts file. Review and refine — for example, marking optional fields with ?.
Refine the output
Types are inferred from sample values. Fields that could be null in real responses should be changed to string | null or T | undefined after generation.
When to use this tool
Stop writing TypeScript interfaces by hand. Use this tool when:
- →You receive a new API response and need to type it for your TypeScript project immediately
- →You're adding TypeScript to an existing JavaScript project with existing JSON data structures
- →You want to generate a base interface from a JSON payload and refine it with more specific types
- →You're documenting an API and need TypeScript type definitions for the docs or SDK
- →You're working with large JSON responses that have dozens of nested fields