skip to main content

Jixun's Blog 填坑还是开坑,这是个好问题。

Convert JSON data to TypeScript interfaces

An useful tool to quick convert JSON data to TypeScript interfaces. All you need to do is to paste the data in and click 点我转换(Click to Convert), and is done!

Example input:

{
  "url": "https://jixun.moe/",
  "posts": [
    { "title": "日记", "date": "2016.06.08" },
    { "title": "随笔", "date": "2016.06.09" }
  ],
  "last-update": 1465388410306
}

Example output:

interface IUnknown {
  url: string;
  posts: IPost[];
  "last-update": number;
}


/* 自动生成的 Interface */

interface IPost {
  title: string;
  date: string;
}

Generated name may not make much sense, just rename it in your IDE / editor.

For example with Visual Studio Code, move the cursor to the variable name and press F2 to rename.

Link: Json 对象 → TypeScript Interface 在线转换器


TODO: Update English UI for this tool.

Creative Commons Licence This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Comments