Skip to content

JSON Schema Generator

Paste a JSON sample (like an API response) and get a JSON Schema instantly: nested objects, arrays, required fields, nulls and formats like email, date-time, URI and UUID. Draft 2020-12 or draft-07.
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "email": {
      "type": "string",
      "format": "email"
    },
    "website": {
      "type": "string",
      "format": "uri"
    },
    "signedUpAt": {
      "type": "string",
      "format": "date-time"
    },
    "age": {
      "type": "integer"
    },
    "score": {
      "type": "number"
    },
    "verified": {
      "type": "boolean"
    },
    "nickname": {
      "type": "null"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "addresses": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "postcode": {
            "type": "string"
          }
        },
        "required": [
          "city",
          "country"
        ]
      }
    }
  },
  "required": [
    "id",
    "email",
    "website",
    "signedUpAt",
    "age",
    "score",
    "verified",
    "nickname",
    "tags",
    "addresses"
  ]
}

What the generator infers

JSONJSON Schema
"ada@example.com"{ "type": "string", "format": "email" }
"2026-10-24T09:30:00Z"{ "type": "string", "format": "date-time" }
36{ "type": "integer" }
9.5{ "type": "number" }
[1, "a", null]{ "type": "array", "items": { "type": ["integer", "string", "null"] } }
key missing in some array itemsleft out of required

Formats detected: date-time, date, email, URI, UUID and IPv4. A sample can't show everything (enums, minimum and maximum values, patterns), so tighten the schema by hand where you know more.

Validate data against the schema

JavaScript
import Ajv2020 from "ajv/dist/2020.js"; // npm install ajv ajv-formats
import addFormats from "ajv-formats";

const ajv = new Ajv2020();
addFormats(ajv); // email, date-time, uuid, uri…
const validate = ajv.compile(schema);

if (!validate(data)) console.log(validate.errors);

Related tools

Need TypeScript types or a Zod schema instead? Use JSON to TypeScript & Zod. Turning an API into an AI agent tool? The AI Tool Generator builds the schema from a curl command. Clean up messy JSON first with the JSON formatter.

Frequently asked questions

What is JSON Schema?

A standard for describing the shape of JSON: which fields exist, their types, which are required and what formats they follow. It's used to validate API requests and responses, document APIs (OpenAPI uses it), generate forms, and define AI tool parameters and structured outputs.

Which draft should I use?

Draft 2020-12 is the current version and what OpenAPI 3.1 uses. Choose draft-07 for older tools and libraries that don't support 2020-12 yet. For the schemas this generator writes, the two differ only in the $schema line.

How are required fields decided?

A key is required if it appears in every object of that shape in your sample. When an array holds several objects, keys missing from some of them become optional. Untick Required fields to make everything optional.

What does 'No extra properties' do?

It adds additionalProperties: false to every object, so validation fails if the data contains keys the schema doesn't list. Use it for strict API contracts, and it's required for OpenAI's strict structured outputs.

Can I use the schema for AI structured outputs or tool calls?

Yes. OpenAI, Claude and Gemini all accept JSON Schema for tool parameters and structured outputs (with some keyword limits per provider). To turn an API request into a complete AI tool, use the AI Tool Generator.

More free developer tools