Skip to main content

JSON Schema Generator & Validator

Infer JSON Schema from JSON payload and validate JSON against schema specifications

Input sample JSON

One object infers required fields. An array of objects reveals fields that may be optional. Input is limited to 1,000,000 characters.

Inferred Draft-07 JSON Schema

Was this JSON Schema Generator & Validator helpful?

Help us keep tools reliable, fast, and bug-free.

What you can do with JSON Schema Generator & Validator

  • Generate json schema from json
  • Validate json against schema

How this data and SQL utility works

Infer a JSON Schema Draft-07 contract from one JSON value or multiple sample records, and validate a JSON document against a supplied Draft-07 schema.

Example input

[{"userId":"usr_1","email":"[email protected]","age":29},{"userId":"usr_2","email":"[email protected]","tags":["admin"]}]

Example output

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Inferred Schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "userId": {
        "type": "string"
      },
      "email": {
        "type": "string"
      },
      "age": {
        "type": "integer"
      },
      "tags": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "userId",
      "email"
    ]
  }
}

Practical workflow

  1. Paste one JSON value or an array of representative records into the inferrer.
  2. Review the generated Draft-07 schema; for arrays of objects, properties missing from some records remain optional.
  3. Switch to Schema Validator, enter a JSON document and a Draft-07 schema, and read all reported constraint errors.
  4. Copy the inferred schema when you are ready to use it in your application.

Common use cases

  • Defining strict API validation contracts for backend microservices.
  • Configuring OpenAPI/Swagger request body schema definitions.
  • Generating automated test data mockers and contract tests.

Important notes and limitations

  • The inferrer merges object properties across sample arrays, marks only common properties required, and preserves mixed value types with anyOf.
  • The validator uses Ajv with standard formats and reports every detected constraint error with its JSON Pointer path.
  • Generation and validation support JSON Schema Draft-07 only. Validation is local and does not fetch remote $ref documents.
  • Each JSON document or schema is limited to 1,000,000 characters to keep parsing and validation work bounded in the browser.

JSON Schema validation & CLI schema generators

Validate JSON against schema with ajv-cli

npx -y ajv-cli validate -s schema.json -d data.json

Validates data files against Draft-07 or Draft 2020-12 JSON Schema specifications with detailed error output.

Infer JSON Schema from sample JSON payload

npx -y quicktype --src sample.json --src-lang json --lang schema -o schema.json

Infers property types, required arrays, and nested object definitions directly from sample data.

Ajv validation & draft version troubleshooting

strict mode: unknown keyword '...' (Schema compilation error)

Cause: Using Draft-04 keywords inside Draft 2020-12 schema or mixing unrecognized custom validator attributes.

Solution: Specify the correct '$schema' URI (e.g. 'https://json-schema.org/draft/2020-12/schema') and verify schema compliance.

Additional properties allowed unintentionally

Cause: Omission of '"additionalProperties": false' at root and nested object schema levels.

Solution: Explicitly declare 'additionalProperties: false' to reject payload tampering and unrecognized keys.

Continue your workflow

Frequently asked questions

Which JSON Schema draft specifications are supported by the generator?

The inferrer generates Draft-07 schemas. The validator supports Draft-07; Draft 2019-09 and Draft 2020-12 schemas are not supported by this tool.

How are optional properties determined from sample payloads?

For an array of sample objects, the inferrer merges their properties. A property is listed in required only when it appears in every object in the array.

Can I validate an incoming JSON payload against my schema?

Yes. Switch to Schema Validator and provide both texts. Ajv checks the document against Draft-07 constraints such as type, required, enum, bounds, patterns, and standard formats, then lists all failures with their paths.