Skip to content
gohacks.dev
APIs

JSON Schema Generator

Generate a draft 2020-12 JSON Schema from a sample document, with types, nested properties, required keys and nullable fields.

Free · No sign-up · Your inputs stay in your browser

Input

Generate a JSON Schema from a sample

Output

JSON Schema (2020-12)

1,325 characters

A starting point, not a contract: one sample cannot tell a schema about formats, enums or ranges. Add format: email, minimum and enum by hand where the data has rules.

Runs in this browser. Nothing you paste is sent to a server.

From sample to contract

A generated schema describes the data you had, not the data that is allowed. Tighten it before relying on it: add format for emails, dates and URIs, minimum and maximum for numbers, enum for fixed sets, and decide whether additionalProperties should be false. The vocabulary is defined at json-schema.org.

Where schemas are used

OpenAPI 3.1 describes request and response bodies with the same 2020-12 dialect, so a schema written here drops into an API description. Validators exist for every language: Ajv in JavaScript, opis/json-schema in PHP, jsonschema in Python.

Share

Frequently asked questions

Which draft does it generate?
Draft 2020-12, the version OpenAPI 3.1 uses. The $schema keyword at the top says so.
How is required decided?
A key is required if every object in the sample at that position has it. With a single object, every key is required, so loosen it by hand.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools