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
Can I Add My Own Statutory Holidays to the Workday Calculator and How Do I Set It Up?
This article explains the steps and setup methods for adding custom holidays to the workday calculator, and answers common questions one by one, including troubleshooting result deviations, differences from spreadsheet functions, mobile troubleshooting, and project scheduling estimation, helping you quickly get accurate workday counts locally in your browser.
tool-tutorialsWhat's the difference between PDF to image and screenshot saving, and which should you choose?
The core difference between PDF to image and screenshot saving is: PDF to image renders the entire page, while a screenshot is just a raster copy of the visible screen area. If you need the whole page, batch processing, or a fixed resolution, choose PDF to image; if you only need a small portion of the screen and want speed, a screenshot is easier. Understanding the difference between PDF to image and screenshots helps you avoid the common pitfall of "blurry text when captured, and a mess when printed".
tool-tutorialsWhat to Do When XML to JSON Large File Conversion Gets Stuck
This article provides troubleshooting steps for XML to JSON large file conversion getting stuck, methods to fix incorrect structure, differences from manual format changes, mobile usability, key points for choosing no-install online tools, and how to preserve attributes during API debugging, helping you complete conversion locally and reduce repeated debugging.
tool-tutorialsHow to Fix the Color Picker Error Unable to Read Screen Colors
This article clearly explains the causes and handling order of the color picker unable to read screen colors error, provides step-by-step screenshot color picking operations, and answers common questions such as mobile browser color picking, inconsistent colors, and checking color values during API debugging, helping you stably obtain usable color values in the browser.