JSON to JSON Schema: infer a working contract from any sample
The site could validate your JSON against a schema — but not write the schema. That gap is now closed, client-side.
For a long time this site could do one half of the schema job: it ships a full JSON Schema validator (draft 2020-12, ajv-powered, all in your browser) — but if you arrived without a schema, it could only wish you luck. Developers sketching an API contract from a real response, or writing tests around a config file, were left to hand-roll $schema documents by hand or hunt for a generator elsewhere. That gap is now closed: paste a sample, get a working schema.

What it infers
- Types, precisely —
integervsnumber(no morenumberfor every count),boolean,null, and recursion through nested objects. - Required fields — every key present in the sample is required, and
additionalProperties: falsemeans a typo in a future payload gets caught instead of silently accepted. - Array shapes — elements merge into a single
itemsschema; a heterogeneous array becomes aoneOfof its distinct shapes; an empty array stays permissive () because it honestly carries no information. - String formats —
email,uri,date,date-time, anduuidare detected from the value, so validators with format checking (ajv-formats, CI linters) get the extra rigor for free. - Enums, conservatively — an array of strings with at most five distinct values becomes an
enum. Per-field enums from a single sample would just echo the sample back, so we leave that call to you.
How to use it
Open the JSON to JSON Schema generator, paste a real API response or config sample into the left box, and the schema regenerates as you type. Copy it into your repo, your OpenAPI definition, or your test fixtures. When the contract starts evolving, paste other payloads in and re-check them with the Schema validator — generator and validator now sit one click apart.
No accounts, no ads, no uploads
This generator is deliberately friction-free. The draft is current and declared in the document (2020-12, the standard — not an older dialect). The inference runs entirely client-side: a schema describing your private API response never touches our servers, or anyone else's. There is no account to create, no paywall in front of the Copy button, and no ad sitting between you and the output. And because the site already ships a full draft-2020-12 validator, the generator is wired straight into the tool that consumes its output — generate, validate, iterate, all in one tab.
As always, every claim above was verified against real payloads before shipping: a nested order sample exercised integer-vs-number typing, the merged array-items shape, and all three string formats. If a case comes out wrong, let us know — it's twenty lines of test to reproduce.
Try it in your browser
Every tool on JSON Formatter App runs 100% client-side. No upload, no signup.
Open the editor