1Input JSON
2TypeScript Interface Code
Online JSON to TypeScript Interface Type Definition Generator
Paste JSON data on the left to automatically generate the corresponding TypeScript export interface definitions. It auto-infers string, number, boolean, arrays, and nested interface types. Perfect for frontend devs quickly adding type constraints to API responses. Processed 100% locally in your browser, data is never uploaded.
Features
- Auto-infers basic types like
string,number,boolean,null,any - Recursively generates independent
interfacedefinitions for nested objects - Maps JSON arrays to TypeScript array types (e.g.,
string[],SubType[]) - Uses the
exportkeyword for easy module importing - Customizable root interface name (e.g., IApiResponse, UserModel)
Applicable Scenarios
- React/Vue Dev: Quickly generate types for axios/fetch JSON responses
- API Integration: Convert backend API doc examples to usable TypeScript types
- Swagger/OpenAPI: Quickly convert response example JSON to interface types
- Local Data: Add type constraints to JSON config files or mock data
Frequently Asked Questions
The current tool infers field types based on JSON example data, defaulting all fields to required. If you need to mark a field as optional (add
? after field name), you can modify it manually after generation.Yes. The generated
interface uses the export keyword and can be directly imported and used in .ts or .tsx files. With axios or fetch, you can constrain response types via generics, e.g., axios.get<IResponse>('/api/xxx').Completely safe. All JSON parsing and TypeScript interface generation happen locally in your browser. Data is never uploaded to any server, and it works offline.