Search for a command to run...
从 JSON 示例推断类型、格式与必填字段,快速生成可直接使用的 JSON Schema。
最多可输入 200000 个字符。
决定根节点写入的 $schema 值。
推断选项
仅当所有示例都匹配时才添加 format,例如 email 或 uuid。
只有在合并后每个对象中都出现的键才标记为必填。
为每个对象写入 additionalProperties: false。
为每个标量值添加首次出现的值作为 examples 数组。
当重复字符串的不同取值不超过 10 个时生成 enum。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"active": {
"type": "boolean"
},
"loginCount": {
"type": "integer"
},
"deletedAt": {
"type": "null"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"website": {
"type": "string",
"format": "uri"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
},
"ratings": {
"type": "array",
"items": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
]
}
},
"profile": {
"type": "object",
"properties": {
"birthDate": {
"type": "string",
"format": "date"
},
"timezone": {
"type": "string"
},
"lastIp": {
"type": "string",
"format": "ipv4"
}
},
"required": [
"birthDate",
"timezone",
"lastIp"
]
},
"orders": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
},
"total": {
"type": "number"
},
"note": {
"type": "string"
}
},
"required": [
"sku",
"quantity",
"status",
"total"
]
}
},
"labels": {
"type": "array",
"items": {}
}
},
"required": [
"id",
"name",
"email",
"active",
"loginCount",
"deletedAt",
"createdAt",
"website",
"tags",
"ratings",
"profile",
"orders",
"labels"
]
}What
JSON Schema 是描述 JSON 数据结构的规范,可用于自动校验。该工具解析示例数据,推断类型、必填键、字符串格式与嵌套结构,并输出 Draft 2020-12 或 draft-07 格式。
Cases
为 REST API 快速搭建请求与响应校验
记录第三方 Webhook 的载荷结构
基于真实数据生成 OpenAPI 组件 Schema
添加契约测试以捕获响应的破坏性变更
在 CI 中于部署前校验配置文件
为 LLM 工具调用参数定义严格的 Schema
How To
粘贴有代表性的 JSON 示例,调整推断选项,然后复制结果。
把能代表真实结构的示例数据粘贴到输入框。
根据所用校验器选择 Draft 2020-12 或 draft-07,$schema 会随之改变。
开关格式检测、必填键、additionalProperties、examples 与 enum。
把生成的结果粘贴到校验器、OpenAPI 文档或测试代码中。
Knowledge
FAQ