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. Paste a JSON object into the left panel。
  2. Set the root interface name and choose interface or type alias。
  3. Toggle readonly or null-to-optional as needed。
  4. Copy the generated TypeScript definitions from the right panel — conversion runs entirely in your browser。

範例

  • 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`。

生產環境使用前請驗證輸出。無擔保 — 參見 條款.