HTML Tools

Free JSON Schema Generator & Validator

Two tools in one: generate a JSON Schema from sample JSON data by inferring types, required fields, and structure, or validate a JSON document against an existing schema. Supports JSON Schema Draft 4, Draft 7, and Draft 2020-12. The generator produces clean schemas with type inference, required field detection, and example values baked in.

Loading tool...

What is JSON Schema Generator & Validator?

JSON Schema Generator and Validator helps you create and validate JSON Schema definitions. The generator examines sample JSON data and produces a schema that describes its structure including property types, required fields, nested object schemas, and array item schemas. The validator checks a JSON document against a schema and reports all validation errors with descriptions of what failed and why.

quickAnswer

Generate JSON Schema from sample data with type inference and required field detection, or validate JSON against an existing schema. Supports Draft 04, Draft 7, and Draft 2020-12. Results show inferred schemas or detailed validation errors.

limitations

  • External $ref references are not resolved during validation. The schema and data must be self-contained for validation to work. Use a schema bundling tool to merge multi-file schemas before validating.
  • Generated schemas are based on the structure and types present in the sample data. The generator cannot infer constraints like minimum, maximum, pattern, or format -- these must be added manually.
  • Schema validation follows the selected draft specification. Features from different drafts cannot be mixed. Draft 2020-12 schemas are not compatible with Draft 04 validators and vice versa.

How to use this tool

  1. Switch between Generate (create schema from sample data) and Validate (check JSON against a schema) modes.
  2. In Generate mode: paste sample JSON, select a schema draft (Draft 04, Draft 07, or 2020-12), and click Generate. Review the inferred schema.
  3. In Validate mode: paste your JSON data on the left and your schema on the right, then click Validate.
  4. Copy the generated schema or reviewed validation results. Adjust inference options like marking all properties as required.

What you can use it for

  • Generate a JSON Schema from sample API response data to document your REST API endpoint contract.
  • Validate incoming API payloads against a schema to catch malformed data before it enters your pipeline.
  • Create a schema for JSON configuration files to enable IDE autocompletion and validation in editors like VS Code.

Use cases

Practical examples

example

Generating a schema from a user API response

A developer receives sample output from a new API endpoint showing user profiles. They paste the JSON into the generator, select Draft 2020-12, and get a complete schema with type constraints for id (integer), name (string), email (string, format email), and addresses (array of objects). They add this schema to their API documentation.

example

Validating a configuration file against a schema

A team maintains a JSON configuration file for their build tool. They have a schema that defines allowed properties and their types. They paste the config file and schema into the validator, which catches a misspelled property name and a number where a string was expected. The validation report shows each error with the exact path and expected type.

Common mistakes

  • Assuming generated schemas are complete -- the generator infers types from sample data but cannot detect optional-by-intent properties. Review the generated schema and adjust required fields and constraints based on your actual data model.
  • Using Draft 04 features with a Draft 2020-12 validator -- each draft has breaking changes. The $schema keyword in the schema must match the draft version you select. This tool lets you choose the draft version explicitly to avoid confusion.
  • Expecting the generator to infer format constraints like email or uri automatically -- the generator identifies string types but does not automatically add format keywords. Add format constraints manually if you need format validation.

verification

  1. In Generate mode, paste {"name":"Alice","age":30,"email":"alice@example.com"}, select Draft 2020-12, and click Generate. Confirm the output schema defines name and email as type string and age as type integer, with all three properties in the required array.
  2. In Validate mode, paste the generated schema as the schema input and the sample JSON as the data input, then click Validate. Confirm that validation passes with no errors.

FAQ

Questions about JSON Schema Generator & Validator

What is the difference between JSON Schema Draft 4, Draft 7, and 2020-12?

Draft 04 is the original widely-adopted specification. Draft 7 added if/then/else conditional validation and $comment. Draft 2020-12 introduced $defs (replacing definitions), unevaluatedProperties, and vocabulary extensibility. Draft 2020-12 is not backward-compatible with Draft 04 schemas -- the $schema URL must match the draft version.

Does the generator mark all sample properties as required?

By default, properties that exist in all sample objects are marked as required. Properties that appear in only some samples are marked as optional. You can toggle an option to mark all properties as required or to leave all properties optional, depending on your schema design needs.

Can I validate JSON against a schema with external $ref references?

No. The validator only supports schemas that are entirely self-contained. Remote $ref references (to other URLs or files) are not resolved. For validation against schemas with references, bundle all sub-schemas into a single file first using a schema bundling tool.

Related tools

More html tools

Html

ARIA Live Region Generator

Generate accessible ARIA live region HTML snippets with role, aria-live, aria-atomic, and aria-relevant attributes. Includes optional JavaScript update function.

Open tool

Html

CSP Hash Generator

Generate CSP hash values for inline scripts and styles. Hash exact code content with SHA-256, SHA-384, or SHA-512 and get the matching CSP directive snippet.

Open tool

Also try

Also try

Seo

AI Crawler robots.txt Builder

Build a robots.txt policy for AI crawlers. Choose from open, selective, or strict presets and block specific AI training bots while allowing search engines.

Open tool