返回工具列表

JSON Schema Generator

Data

Generate 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.
保持更新

比任何人都更早获得新工具。

先人一步获取新工具。加入5000+开发者的行列,每周获取最新在线工具、编码技巧和效率工具摘要。绝无垃圾邮件。

© 2026 TinyToolbox. 保留所有权利。

隐私优先。广告支持。永远免费。

[H4CK]