JSON 转 JSON Schema 在线工具怎么用?
不用装任何依赖,打开网页、粘贴 JSON、点一下「生成 Schema」,就在浏览器里得到标准 JSON Schema。
三步完成转换
- 在左侧输入框粘贴你的 JSON(或直接点「示例」载入样例)。
- 点击「生成 Schema」,右侧立即出现 JSON Schema。
- 点「复制结果」粘贴到你的代码、配置文件或接口文档里。
一个真实例子
把下面这段 JSON 粘进去:
{
"id": 1024,
"name": "Ada Lovelace",
"active": true,
"tags": ["math", "computing"],
"profile": { "city": "London", "followers": 1200 }
}
工具会输出:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"active": { "type": "boolean" },
"tags": { "type": "array", "items": { "type": "string" } },
"profile": {
"type": "object",
"properties": {
"city": { "type": "string" },
"followers": { "type": "integer" }
},
"required": ["city", "followers"]
}
},
"required": ["id", "name", "active", "tags", "profile"]
}
为什么选在线、纯前端的方式
- 零安装:Vite + 浏览器即可,不需要 Node 脚本。
- 隐私安全:转换全部在本地完成,你的 JSON 不会上传到任何服务器。
- 即时预览:改一个字段立刻能看到 Schema 变化,适合调接口文档。