Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>JSON to TypeScript Interface HelperNew to Visual Studio Code? Get it now.
JSON to TypeScript Interface Helper

JSON to TypeScript Interface Helper

matanlong

|
11 installs
| (0) | Free
Easily convert JSON to TypeScript interfaces with right-click menu or command palette.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

JSON to TypeScript Interface Helper

一个强大的VSCode扩展,帮助你快速将JSON数据转换为TypeScript接口定义。

功能特点

  • 🚀 直接在编辑器中将JSON转换为TypeScript接口
  • 🎯 支持右键菜单和命令面板操作
  • ⚙️ 丰富的配置选项
  • 🎨 支持多种属性命名风格转换
  • 📦 支持嵌套对象和数组
  • 🛡️ 完善的错误处理

使用方法

  1. 在编辑器中选中要转换的JSON文本
  2. 右键点击选中的文本,选择 "Convert JSON to TypeScript Interface" 或 使用命令面板(Ctrl+Shift+P)输入 "Convert JSON to TypeScript Interface"
  3. JSON将被自动转换为TypeScript接口定义

示例

输入JSON:

{
  "user_name": "John Doe",
  "age": 30,
  "is_active": true,
  "address": {
    "street": "123 Main St",
    "city": "Boston"
  },
  "hobbies": ["reading", "gaming"]
}

输出TypeScript接口:

export interface RootType {
  user_name: string;
  age: number;
  is_active: boolean;
  address: {
    street: string;
    city: string;
  };
  hobbies: string[];
}

配置选项

在VSCode设置中可以自定义以下选项:

  • json-to-ts-helper.useInterface: 使用interface而不是type定义(默认:true)
  • json-to-ts-helper.optionalProperties: 生成可选属性(默认:false)
  • json-to-ts-helper.indentSpaces: 缩进空格数(默认:2)
  • json-to-ts-helper.convertPropertyNames: 属性命名风格转换
    • none: 保持原样(默认)
    • camelCase: 驼峰命名
    • PascalCase: 帕斯卡命名
    • snake_case: 蛇形命名

更新日志

0.0.1

  • 初始版本发布
  • 支持基本的JSON到TypeScript接口转换
  • 添加右键菜单和命令面板支持
  • 实现配置选项

问题反馈

如果你发现任何问题或有功能建议,欢迎在GitHub仓库提交issue。

许可证

MIT


Following extension guidelines

Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.

  • Extension Guidelines

Working with Markdown

You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:

  • Split the editor (Cmd+\ on macOS or Ctrl+\ on Windows and Linux).
  • Toggle preview (Shift+Cmd+V on macOS or Shift+Ctrl+V on Windows and Linux).
  • Press Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets.

For more information

  • Visual Studio Code's Markdown Support
  • Markdown Syntax Reference

Enjoy!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft