Loading JSON Schema Generator...

JSON Schema Generator

Paste a sample JSON payload and instantly generate a valid JSON Schema — Draft 2020-12 or Draft-07.

Sample JSON

JSON Schema

Generate a JSON Schema from a Sample Payload

This free online tool converts any sample JSON — an API response, a config file, a webhook body — into a valid JSON Schema document. Paste your JSON, choose a draft version, and get a schema you can use for validation, documentation, or contract testing, with no need to write the schema by hand.

How It Works

Why Generate a Schema Instead of Writing One?

Writing a JSON Schema by hand for a deeply nested payload is tedious and easy to get subtly wrong — a missing type keyword or an incorrect nesting under properties can make validation silently pass when it shouldn't. This tool infers types directly from real data, merges the shape of every object in an array so optional fields are handled correctly, and can detect common string formats such as dates, emails, URIs, and UUIDs.

Privacy

All schema generation happens entirely in your browser using JavaScript. Your JSON is never uploaded to a server, so it is safe to use with real API responses and internal payloads.

JSON Schema Generator — Options Explained

JSON Schema has several dialects and configuration choices that change the generated output. Here is what each option on this page controls.

Draft 2020-12 vs Draft-07

Draft 2020-12 is the current JSON Schema specification version; Draft-07 is still widely supported by older validators and tools such as some IDEs and OpenAPI 3.0 tooling. Pick whichever your validator or framework expects.

Mark All Properties as Required

When enabled, every key present in your sample becomes part of the schema's required array. Turn this off if your sample is only a partial example and some fields may legitimately be absent.

Disallow Additional Properties

Sets additionalProperties: false on every object in the schema, so validation fails if the real data contains extra keys not seen in your sample. Useful for strict API contract testing.

String Format Detection

Automatically adds a format keyword (date-time, date, email, uri, uuid) when a string value matches a recognizable pattern, giving validators extra context beyond a plain type: "string".

Who Uses This Tool?

API Developers

Generate a schema from an example response to validate request/response bodies in an OpenAPI spec, Express middleware, or FastAPI/Pydantic model.

QA & Contract Testing

Turn a captured API response into a schema, then validate future responses against it to catch breaking changes automatically in CI.

Data Engineers

Generate a schema for JSON documents stored in a document database or data lake to document the expected shape of the data.

Tooling & Config Authors

Produce a starter schema for a JSON configuration file so editors like VS Code can offer autocomplete and validation via $schema.

Frequently Asked Questions

What is a JSON Schema?

A JSON Schema is itself a JSON document that describes the structure, types, and constraints of other JSON data — which fields exist, their types, which are required, and more. It's used for validation, documentation, and code generation.

Which draft version should I choose?

Use Draft 2020-12 for new projects — it's the current specification. Use Draft-07 if your validation library, IDE, or framework (some OpenAPI 3.0 tooling, for example) doesn't yet support the newer draft.

How does it handle arrays with objects that have different fields?

The tool merges the shape of every object in the array. A field present in every item stays in required (if that option is enabled); a field present in only some items is dropped from required but still described in properties.

Can the generated schema validate my JSON later?

Yes. The output is a standard JSON Schema document you can use with any compliant validator (Ajv, jsonschema in Python, etc.) or reference via the $schema keyword in editors that support JSON Schema-based autocomplete.

Is my JSON data uploaded anywhere?

No. All schema generation happens locally in your browser with JavaScript. Nothing is sent to a server.

Can I generate typed code instead of a schema?

Yes — use the JSON to TypeScript, Python & Go Code Generator to produce a TypeScript interface, Python dataclass, or Go struct from the same kind of sample payload.

Built by Deepak Kumar — a developer who wanted a JSON tool that respects your privacy. All processing happens in your browser. Your data never leaves your device.