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 Cron Expression Generator: Complete Beginner Steps
Use an online tool to select the five time fields, automatically generate a standard Cron expression with a human-readable time explanation, and learn to troubleshoot execution time deviations caused by time zones and field counts, so complex schedules no longer rely on guesswork.
tool-tutorialsHow to Use an Online CSV to JSON Tool: Beginners Can Get Started in Three Steps
Use a three-step process to complete an online CSV to JSON tool operation, covering option settings, result validation, error troubleshooting, large file handling, mobile operation, and API debugging scenarios. Beginners can follow along to get usable JSON data.
tool-tutorialsWhat Is HTML Formatting? A Beginner's Guide to the Key Points
Use a browser-based HTML formatting tool that runs locally to restore compressed or messy HTML into an indented, readable structure. Also understand the difference between formatting and minification, the troubleshooting order for messed-up indentation, and how to handle large files getting stuck and mobile no-install solutions.
tool-tutorialsThe Difference Between JS Formatting/Minification and Manual Code Cleanup: Which Is More Suitable
The difference between JS formatting/compression and manual cleanup comes down to automation versus human judgment. Formatting and compression are handled in bulk by tools according to rules—fast and consistent; manual cleanup is more flexible, suited to scenarios with special naming conventions or complex logic. For everyday development and debugging, use tools first and save human effort for the parts that truly need judgment. Understanding what JS formatting and compression means helps you decide when to use it and when to stop.