返回工具列表
JSON Schema Generator
DataGenerate draft 2020-12 JSON Schema documents from sample JSON.
ttb run json-schema-generator
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TinyToolboxSchema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"email": {
"type": "string"
},
"active": {
"type": "boolean"
},
"roles": {
"type": "array",
"items": {
"type": "string"
}
},
"profile": {
"type": "object",
"properties": {
"displayName": {
"type": "string"
},
"age": {
"type": "integer"
}
},
"required": [
"displayName",
"age"
],
"additionalProperties": false
}
},
"required": [
"id",
"email",
"active",
"roles",
"profile"
],
"additionalProperties": false
}分享此工具:
如何使用 JSON Schema Generator
Paste a representative JSON document and the tool generates a draft 2020-12 JSON Schema in real time. Arrays infer item schemas, nested objects become nested property maps, integer vs number is preserved, and required keys are inferred from the sample document you provide.
1
Paste sample JSON
Use a real payload or config file sample that reflects the structure you want to validate.
2
Review the schema
Check the generated object, array item definitions, and required fields to confirm they match your expectations.
3
Copy into your stack
Copy the schema and drop it into Ajv, OpenAPI tooling, validation docs, or internal contracts.
常见问题
Does one sample capture every possible shape?+
No. Like any inferred schema generator, the result is only as complete as the sample JSON you provide, so edge-case variants may require manual edits.
What draft does it target?+
The generated document includes the JSON Schema draft 2020-12 $schema URL for modern validator compatibility.