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 an ASCII Table Lookup: Complete Step-by-Step Guide for Beginners
Master the three input methods of ASCII table lookup—character, decimal, and hexadecimal—understand the coverage difference between ASCII and Unicode, and learn to troubleshoot practical issues such as unresponsive pages, mobile input, invisible characters in API debugging, and large-file sampling, so encoding verification is done right the first time.
tool-tutorialsHow to Convert HTML to Markdown? Step-by-Step Guide for Browser-Based Local Conversion
Use a browser-based local conversion tool to turn HTML into Markdown without uploading files. Paste the source code to get clean text. This article provides a five-step workflow, explains the causes and fixes for errors in headings, tables, and links, and describes the cleaning order for API response data, helping you complete the conversion in minutes and reduce rework.
tool-tutorialsHow to Use an Online JS Formatter and Minifier: No-Install Steps
Paste code, choose format or minify, copy the result—three steps to format and slim down JavaScript code. This article explains the no-install operation steps, the difference between formatting and code beautification, how to troubleshoot lag on large files and when it's not working, and practical usage in API debugging, helping you quickly process JS code without installing any software.
tool-tutorialsHow to Use an Online CSS Formatter and Minifier: Format Code Directly Without Installation
Paste CSS code and switch between format and minify modes with one click. Processing runs locally in the browser without uploading code. Includes methods for speeding up large files, mobile operation, and troubleshooting style failures. Follow along to finish code organization and pre-deployment minification.