JSON to TypeScript
Paste JSON and get TypeScript interfaces, including nested objects and arrays
Instructions
JSON 转 TypeScript 接口使用说明
功能简介
拿到一份接口返回的 JSON,要手写 TypeScript 类型很费时间。这个工具直接读 JSON 结构,递归推断出嵌套的 interface。
使用方法
注意事项
❓ FAQ
What if the object types in an array are inconsistent?
The tool generates one interface for each distinct structure and writes the array element type as a union, for example `(User | Admin)[]`. You can narrow it down after generation based on your actual business logic.
Why is the type of a null field null?
Because there is only this one piece of data, it is impossible to tell whether it will be a string or a number later. It is recommended to add all the types that have appeared in real data, or manually change it to `string | null`.
Does it support generating Go or Java types?
Currently it only generates TypeScript. If you want to see the structure first, the nested interface names inferred by this tool are not hard to rewrite as structs in other languages.
🔗 Related Tools
📝 Related Articles
How to Use a Currency Converter: A Three-Step Operation Process for Beginners
This article provides executable troubleshooting steps in the order of "environment—input—data," helping you quickly locate issues such as a currency converter not responding, abnormal results, and mobile freezing, and explains the differences between web tools and the system's built-in conversion, so you can solve it yourself without repeatedly going back to the search results page.
tool-tutorialsHow to Convert JSON to CSV: Complete Beginner Steps
Paste JSON of any level into the browser and convert it to CSV. This article provides complete steps for judging the data structure, handling nested fields, troubleshooting conversion failures, dealing with large files, and API debugging, so you can get a usable spreadsheet file without repeated trial and error.
tool-tutorialsHow to Deduplicate and Sort Text Without Changing the Original Order
Use a locally running deduplication tool to process text, keep the first occurrence position, delete duplicates without disrupting the original line order, and also understand the precautions for large file lag, mobile use, and API debugging scenarios, so you can get clean, ready-to-use results in just a few minutes.
tool-tutorialsHow to Use a Countdown Timer: Complete Steps from Setting to Ringing
This guide breaks down how to use a countdown timer into actionable steps, covering duration setting, start/pause, ring troubleshooting, phone mute and background restrictions, maximum duration limits, and the trade-offs between online and system timers, with developer API debugging points included—read it and you can start using it right away.