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
What to Do When Removing Line Breaks from Large Files Causes Lag, Batch Method Comparison
This article explains the causes of lag in batch removing line breaks from large files and compares three methods, clarifying how to remove line breaks, the difference between deletion and replacing with empty, troubleshooting steps when it does not work, and specific approaches for mobile and API debugging scenarios, helping you choose the right route by file size and avoid repeated retries.
tool-tutorialsCan HTML to Markdown Be Used on Mobile? Installation-Free Online Conversion Method
You can complete HTML to Markdown with a mobile browser without installing any app. This article provides step-by-step operations you can follow directly, and gives troubleshooting order for common issues such as large file failures, API response format corruption, and distorted nested lists in tables, helping you stably obtain structurally correct Markdown text on mobile.
tool-tutorialsWhat Is the Difference Between Image to PDF and Online Conversion Tools? Which Is Safer
This article compares the differences between local conversion and cloud conversion in privacy, image quality, and controllability, provides complete operating steps for image to PDF, and focuses on answering four high-frequency issues: file compression, mobile installation-free use, conversion failure, and page ordering, helping you choose the right method according to image sensitivity.
tool-tutorialsWhat is the difference between PDF merging and PDF splitting? Which tool should I use?
After reading this article, you can quickly determine whether to use PDF merging or PDF splitting, master the four-step merging operation, and solve practical questions such as oversized files after merging, mobile operation, file corruption prompts, and browser security.