DevToolCase
Sign in Sign in

Generate a JSON Schema from JSON

Infer a JSON Schema (draft 2020-12) from a JSON sample: types, properties, required keys, array items and common string formats.

Share this result

Encrypted in your browser. The key stays in the link, after “#”: only the people you give it to can read it, not even DevToolCase.

The link works for

Sign in for longer links or links without expiry, and to find them in your account.

Runs entirely in your browser: nothing you type is sent or stored.

Generate a JSON Schema from an example

Writing a schema by hand takes time. Paste a representative JSON sample, an API response for instance, and get a draft 2020-12 schema describing it: a solid base to refine rather than a blank page.

How the schema is inferred

  • Each value gets its type, whole numbers being integer and the others number.
  • Each object lists its properties, all of them required.
  • The items of an array are merged into a single items schema: a property is required only when every item has it, and values of different types give a list of types such as ["string", "null"].
  • With “Detect formats”, strings that are all dates, date-times, email addresses, URIs or UUIDs get a format.

Refine the generated schema

A sample only shows what the data looked like once. Before using the schema as a contract, review it:

  • Remove from required the properties that are optional in reality.
  • Add enum for closed lists of values, minimum or maxLength for limits.
  • Add "additionalProperties": false to reject unknown properties.
  • Add a description to each property: editors and documentation tools show it.

Then validate data with it: “Validate with it” opens the generated schema in the validator.

Add this browser’s favorites to your account?

This browser has 0 favorites that your account does not have:

Either way, this browser keeps its favorites: you find them again after signing out.