Tool Hub

JSON → TypeScript 生成

从 JSON 样本自动生成 TypeScript 接口/类型

从 JSON 样本生成 TypeScript 接口。粘贴 JSON 对象,设置根类型名称,立即获得带推断类型的嵌套接口定义。转换完全在浏览器中运行 — 数据不会离开页面。

输入 JSON

输出 TypeScript
export interface Address {
  city: string;
  zip: string;
}

export interface Root {
  id: number;
  name: string;
  email: string;
  tags: string[];
  address: Address;
}

使用方法

  1. 将HTML代码片段粘贴到输入字段中。
  2. 检查器会立即扫描常见无障碍问题。
  3. 在结果面板中审查被标记的问题。
  4. 修复HTML,实时更新。

示例

  • Pasting {"id":1,"tags":["dev"],"address":{"city":"Seoul"}} with root name Root produces a Root interface with nested Address interface inferred automatically.
  • Enabling "null → optional" changes fields whose value is null from `field: null` to `field?: unknown`.

生产环境使用前请验证输出。无担保 — 参见 条款.