Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>JSON Meta CommentNew to Visual Studio Code? Get it now.
JSON Meta Comment

JSON Meta Comment

tikkhun

|
2 installs
| (1) | Free
Use .meta.json to display inline comments/descriptions above JSON keys
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

JSON Meta Comment

VS Code 插件,为 JSON / CSV 配置文件提供独立注释文件,不修改源文件。

核心概念

源文件                 注释文件
config.json    --->    config.json.meta.json
users.csv      --->    users.csv.meta.json

功能总览

功能 说明
行内注释 在 JSON/CSV 行尾显示灰色斜体注释
CodeLens 按钮 每个 key 上方显示 编辑 / 删除 / 添加注释
自动生成 meta 一键扫描源文件所有 key,生成 meta.json 骨架
结构化描述 支持 type / required / enum / default 等 AJV 风格字段
右键菜单 光标处快速添加/编辑注释

使用流程

1. 打开 JSON/CSV 文件
2. 命令面板 → "JSON Meta: 生成/更新 meta.json"
   (或右键文件 → 生成/更新 meta.json)
3. 自动生成 <文件名>.meta.json,key 设为空字符串
4. 在 CodeLens 点击 "添加注释" 填写描述
5. 注释自动保存到 meta.json

Meta 文件格式

简写 (仅描述)

{
  "server.port": "服务监听端口",
  "db.url": "数据库连接地址"
}

完整 (结构化)

{
  "server.port": {
    "description": "服务监听端口",
    "type": "number",
    "required": true,
    "minimum": 1,
    "maximum": 65535
  },
  "log.level": {
    "description": "日志级别",
    "type": "string",
    "enum": ["debug", "info", "warn", "error"],
    "default": "info"
  }
}

MetaInfo 字段说明

字段 类型 说明
description string 描述文本 (必填)
type string 值类型: string / number / boolean / object / array
required boolean 是否必填
enum array 可选值列表
default any 默认值
minimum number 最小值
maximum number 最大值
minLength number 最小长度
maxLength number 最大长度
pattern string 正则校验
format string 格式约束: date-time / email / uri
const any 常量值
multipleOf number 倍数约束

JSON Key 规则

使用 dot path 表示嵌套层级:

// config.json
{ "server": { "port": 8080 } }

// config.json.meta.json
{ "server.port": "服务监听端口" }

CSV Key 规则

支持 4 种格式:

格式 含义 示例
列名 简写列名 "age": "用户年龄"
column.列名 完整列名 "column.age": "用户年龄"
column.序号 列号 (0-based) "column.0": "第一列"
row.首列值 首列值匹配 "row.John": "John 的数据"
row.序号 行号 (0-based) "row.0": "第一行"

CSV 示例

// users.csv
name,age,email,role
John,25,john@example.com,admin
Jane,30,jane@example.com,user
// users.csv.meta.json
{
  "name": "用户姓名",
  "age": { "description": "用户年龄", "type": "number" },
  "column.0": "第一列: 用户名",
  "row.John": "管理员 John 的数据"
}

命令

命令 触发方式 说明
JSON Meta: 生成/更新 meta.json 命令面板 / 右键菜单 / 资源管理器右键 扫描源文件生成 meta 骨架
JSON Meta: 添加/编辑当前 key 的注释 命令面板 / 右键菜单 光标处快速操作

配置项

配置 默认值 说明
jsonMeta.enabled true 启用/禁用行内注释显示
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft