Dev Tools
純前端檔案不上傳

JSON → TypeScript

貼任意 JSON,**即時推斷 TypeScript 型別** — 自動命名巢狀型別(`users → User`)、合併陣列內共同 shape、把缺漏欄位標為 optional、混合型別 array 推 union。可選 interface / type、根名稱、`readonly`。完全本地,JSON 不上傳。

如何使用
  1. 把任意 JSON 貼進左側(API response、設定檔、fixture 都行)。
  2. 右側立刻產出 TypeScript interface / type,巢狀型別會自動命名(如 User_Address)。
  3. 陣列裡有多個 element shape 不同?工具自動合併 + 標 optional
  4. 頂部選 readonlytype vs interface,一鍵複製到你的 SDK / model 檔。
Tips
  • 想加 JSDoc 註解?先在 JSON 加 _doc 欄位,我會放進產出的 type 裡。
  • API response 有 null 欄位 → 自動推成 T | null,不會省略。

相關工具