JSON Schema Generator

Infer a JSON Schema from representative objects and arrays, then copy or download the Draft 2020-12 result.

Fields

7

Draft

2020

Lines

46

Sample JSON

Generated schema

Schema generated

Schema inferred from the values and field presence in this sample.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "GeneratedSchema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": {
        "type": "integer"
      },
      "name": {
        "type": "string"
      },
      "score": {
        "type": "number"
      },
      "profile": {
        "type": "object",
        "properties": {
          "verified": {
            "type": "boolean"
          },
          "country": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "verified"
        ]
      },
      "tags": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "additionalProperties": false,
    "required": [
      "id",
      "name",
      "profile"
    ]
  }
}

Generated schemas reflect only the supplied sample. Review formats, bounds, enums, and business constraints before production use.

Generate JSON Schema from a Sample

A JSON Schema describes the expected structure and value types of JSON data. This generator infers a Draft 2020-12 schema from the sample you paste, including nested properties, arrays, integers, numbers, strings, booleans, and null values.

For arrays of objects, properties present in every sample item can be marked required. Properties that appear in only some items remain optional. You can also choose whether the resulting object schemas allow properties that were not present in the sample.

What an Inferred Schema Can and Cannot Know

The generator can identify structure and observed types, but one sample cannot reveal every business rule. It cannot reliably infer string formats, minimum and maximum values, regular-expression patterns, enum choices, unique arrays, or conditional requirements unless those rules are provided separately.

Treat the generated schema as a strong starting point, then review it against real valid and invalid payloads. Include samples with optional fields and edge cases when possible.

Use JSON to TypeScript when you need compile-time interfaces. Use the JSONPath Tester to inspect specific fields before refining a large schema.

Frequently Asked Questions

Which JSON Schema draft does this generator use?
The generated schema declares the JSON Schema Draft 2020-12 meta-schema.
How are required properties inferred?
For objects in arrays, a property is required only when it appears in every sample object. You can also disable required fields.
Should I review an automatically generated schema?
Yes. The result reflects only the sample values you provide, so review constraints and edge cases before production use.

Related Tools