Data & CSV

JSON Schema Generator

JSON Schema Generator

Generate a draft 2020-12 JSON Schema from one or more JSON samples.

About this tool

About JSON Schema Generator

Writing a JSON Schema by hand for a real payload takes a long time and it's easy to miss a field. Paste one example, or better, several, and this generator writes a draft 2020-12 schema for you. With several samples it merges what it sees: a field becomes required only if every sample has it, a value that is sometimes null gets the type ["string", "null"], whole numbers stay integer until a decimal shows up, and the objects inside arrays are combined into one items schema. You can paste an array of records, or one JSON document per line (JSON Lines). Options let you detect string formats (date-time, date, email, uri, uuid, ipv4), forbid additional properties for a strict contract, require every field, add enums for short repeated values, and set a title. The result is ready for Ajv, OpenAPI 3.1 or editor validation. Generation runs locally, so production payloads stay on your machine. With your own AI key you can refine the result with descriptions, formats and sensible constraints.

Built and maintained by Abhi JainUpdated

How to Generate a JSON Schema

  1. 1

    Paste samples

    Paste a JSON object, an array of records, or one JSON document per line into the JSON sample(s) pane.

  2. 2

    Choose options

    Set a Title and tick options such as Detect formats, No additional properties or Make every field required.

  3. 3

    Copy the schema

    Copy the JSON Schema from the right pane or download it as schema.json.

JSON Schema Generator: questions and answers

Which JSON Schema version does it produce?

Draft 2020-12, the current version, declared with "$schema": "https://json-schema.org/draft/2020-12/schema". It is also what OpenAPI 3.1 uses.

How are required fields decided?

A property is required when every sample object at that place contains it. Fields that appear in only some samples are left optional. Tick Make every field required to override this.

Why should I give it more than one sample?

One sample can't show which fields are optional, which can be null, or that a number is sometimes a decimal. Several real records give a far more accurate schema.

Can the generated schema be used with Ajv?

Yes. Ajv supports draft 2020-12 through its Ajv2020 class. Formats such as email and date-time need the ajv-formats plugin.

Is my data uploaded?

No. The schema is generated in your browser.

Can AI improve the generated schema?

Yes. Click AI to add property descriptions, accurate formats, enums and constraints, optionally guided by notes you type. The sample and generated schema are sent, and the reply is checked to be a valid JSON Schema before you copy it. It's optional and uses your own AI key (Claude, OpenAI, Gemini, DeepSeek, OpenRouter or a compatible endpoint), sent straight from your browser to that provider; KissThePDF never sees it. Without a key the tool works exactly the same.