Schema and validation

How to validate JSON with JSON Schema

Use JSON Schema to check required fields, data types, arrays, enumerations, and nested response contracts.

10 min read Reviewed July 19, 2026 Professional reference

Document summary

A practical introduction to generating a starting schema, strengthening constraints, and interpreting validation errors.

Key takeaways

  • Use strict, representative input before relying on output.
  • Review structure, types, and edge cases instead of checking only visual formatting.
  • Continue examples inside the connected Bacodev tool to verify the result.
01

Schema validates meaning beyond syntax

A JSON parser checks grammar. JSON Schema can also require specific properties, data types, value ranges, patterns, and array item shapes.

02

Generate a draft from representative data

  1. 1

    Use a response that contains realistic optional and required fields.

  2. 2

    Generate the initial schema.

  3. 3

    Decide which properties are truly required.

  4. 4

    Add constraints such as enum, minimum, pattern, and array limits.

  5. 5

    Test valid and intentionally invalid examples.

03

Declare the schema draft

DraftUse
Draft 7Broad compatibility with established validators
2019-09Modern vocabulary and reference behavior
2020-12Current modern draft used by many new systems
04

Required and typed properties

Invalid
{
  "id": "42"
}
Valid
{
  "type": "object",
  "required": ["id"],
  "properties": {
    "id": {"type": "integer"}
  }
}
05

Read validation errors by path

  • Start with the first failing path.
  • Check whether the data or schema is wrong.
  • Review parent constraints when many child errors appear.
  • Do not mark every generated property as required automatically.
  • Version schemas with the API contract.
06

The parts of a schema that matter first

A JSON Schema describes the shape of a document: the allowed type at the root, the properties an object may have, which are required, and the types of array items.

Start with $schema, type, properties, required, and items. Those five keywords cover most validation needs, from API payloads to configuration files.

  • $schema declares the schema draft, for example http://json-schema.org/draft-07/schema
  • type restricts the value, such as object, array, string, number, or null
  • properties lists the allowed keys and their own schemas
  • required lists the keys that must be present
  • items describes the type of every element in an array
07

Validate a document against its schema

  1. 1

    Generate a starting schema from an example document with the JSON schema generator.

  2. 2

    Open the JSON schema validator and paste both the document and the schema.

  3. 3

    Read the error report; each violation points to the exact path in the document.

  4. 4

    Fix the document or the schema, then re-validate until the report is clean.

08

Frequently asked questions

Which JSON Schema draft does the validator support?

The validator follows the widely used draft-07 vocabulary, which covers type, properties, required, items, enum, and the common constraints used in APIs and configs.

What happens when a required property is missing?

Validation fails and the report names the missing property and its path, so you can fix the document without guessing.

Can I generate a schema from my JSON?

Yes. The schema generator infers types, required keys, and item types from a representative example document, giving you a starting point to refine.

Does schema validation upload my files?

No. Both the document and the schema are processed locally in your browser.

Jump to tool

Apply this workflow in the Json Schema Validator tool

Open tool