Skip to content
rusthacks.dev
Web

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.

Go deeper

Suggested reading

Flat illustration for the post “Request Limits and Slow Client Attacks in Rust Services”, composed around web.
Security

Request Limits and Slow Client Attacks in Rust Services

Slow clients and oversized requests exhaust connections and memory. Set header and body timeouts, body size limits, concurrency limits and keep-alive bounds at the proxy and in the Axum service with Tower layers.

5 min read
Flat illustration for the post “Stale While Revalidate Caching in Rust Services Explained”, composed around perf.
Performance

Stale While Revalidate Caching in Rust Services Explained

Serve the cached value immediately, even if slightly old, and refresh it in the background. Learn the idea, the HTTP Cache-Control directives and an in-process implementation with a freshness window and a grace window.

4 min read

Keep planning

Similar tools