JSON to JSON Schema Converter

Infer a JSON Schema (draft 2020-12 or 07) from a sample, with required fields, nullable types and string formats such as email, date and uuid.

Processed on your device. Files are not uploaded

How to generate a JSON Schema from JSON

  1. Paste your JSON sample

    Paste or type it into the box, or press Try an example.

  2. Choose the version

    Pick the JSON Schema draft your validator supports.

  3. Detect formats

    Optionally recognise strings such as dates and emails.

  4. Tighten the schema

    Mark which fields are required and add limits, since a sample cannot tell the difference.

  5. Copy or download

    Save it as a .schema.json file.

Worked example

This is what JSON to JSON Schema Converter gives for its own sample values. Open the tool above and change anything to try your own.

JSON sample

{
  "id": 42,
  "user-name": "ada",
  "score": 9.5,
  "active": true,
  "tags": ["admin", "beta"],
  "address": { "city": "London", "zip": "N1 9GU" },
  "orders": [
    { "sku": "A-1", "qty": 2, "coupon": "SAVE10" },
    { "sku": "B-7", "qty": 1 }
  ]
}
Schema version
Draft 2020-12
Title (optional)
Detect formats (email, date, uuid, uri)
Yes
Include the sample values as examples
No
Indentation
2 spaces

JSON Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer"
    },
    "user-name": {
      "type": "string"
    },
    "score": {
      "type": "number"
    },
    "active": {
...

About JSON to JSON Schema Converter

Infer a JSON Schema from a sample document. Required fields are the ones present in every item, nullable fields get a null type, and strings that look like emails, dates, date-times, UUIDs or URLs get a format.

FAQs

Which versions are supported?

Draft 2020-12 and draft 07.

Is the schema strict?

It describes your sample, so loosen it where your real data varies, for example by removing required fields.

How do I check data against it?

Use JSON Schema Validator.

Related tools