My Tools Garage

JSON to JSON Schema

Generate a draft-07 JSON Schema from sample data.

in-browser

How to use

  1. 1 Paste a representative JSON sample into the input.
  2. 2 Decide whether to require all properties and include the $schema line.
  3. 3 Read the generated draft-07 schema on the right.
  4. 4 Copy it into your validator or repository.

About JSON to JSON Schema

JSON to JSON Schema turns an example JSON document into a draft-07 JSON Schema that describes its structure.

Writing a schema by hand is tedious and error-prone, especially for nested objects and arrays; this tool reads a representative sample of your data and infers the shape for you, so you have a solid starting point to validate API payloads, configuration files or form submissions.

Paste any valid JSON and the generated schema appears instantly alongside it.

The inference is careful about types: it distinguishes integers from floating-point numbers, recognises booleans, strings, null and nested objects, and looks inside arrays to describe their items — falling back to an anyOf when an array mixes element types.

Objects gain a properties map, and by default every key is listed as required, which you can switch off to produce a looser schema.

You can also drop the $schema declaration if you plan to embed the result inside a larger document.

The output is pretty-printed and ready to copy into your validator of choice, such as Ajv.

Because the work is plain JavaScript running in your browser, your data is never uploaded or logged, which makes it safe for private payloads, and the tool keeps working offline once the page has loaded.

FAQ

Which JSON Schema version is produced?

It produces a draft-07 schema and adds the matching $schema declaration, which you can turn off if you prefer.

How are arrays with mixed types handled?

If every element shares a type, a single items schema is used. When types differ, the items schema becomes an anyOf listing each distinct shape.