WebToolsPlanet
Converter Tools

JSON to JSON Schema Generator

Paste a JSON value and get a JSON Schema that describes its shape — with inferred types, required properties, and merged item schemas for arrays.

Last updated: May 27, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is JSON to JSON Schema Generator?

JSON Schema is a vocabulary for describing the structure and constraints of JSON data. It is the foundation of OpenAPI (which embeds JSON Schema for request/response bodies), `ajv` validation, and many code generators (oapi-codegen, quicktype, json-schema-to-typescript).

Writing a schema by hand from scratch is tedious but starting from an example is fast. This tool walks a JSON value and emits the matching schema: `string` for strings, `integer`/`number` for numbers (integer when `Number.isInteger` is true), `boolean` for booleans, `object` with `properties` and `required` for objects, `array` with `items` for arrays. For arrays of objects, it merges the item schemas so the result describes the union of all keys seen.

How to Use JSON to JSON Schema Generator

1

Paste a JSON value (object, array, or primitive) into the input panel.

2

Optionally set a schema title.

3

Pick a draft: 2020-12 (latest) or Draft-07 (still widely used).

4

Toggle "Mark all properties required" and "Include examples" as needed.

5

Copy the generated schema.

Common Use Cases

  • Generating OpenAPI request/response schemas from example payloads.
  • Bootstrapping ajv or other JSON Schema validators with a known-good payload.
  • Producing JSON Schema input for code generators like quicktype or json-schema-to-typescript.
  • Documenting an undocumented API by capturing the response shape as a schema.

Example Input and Output

A flat JSON object generates a JSON Schema with all properties required.

JSON input
{ "userId": 42, "name": "Alice" }
Generated JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "userId": { "type": "integer" },
    "name":   { "type": "string" }
  },
  "required": ["userId", "name"]
}

Privacy

All conversion happens in your browser. No JSON is sent to a server.

integer vs number

JSON Schema distinguishes integer from number. The tool emits integer when the value passes Number.isInteger and number otherwise. For a value like 1.0 in a "decimal" field, this may pick integer — adjust manually if precise.

Frequently Asked Questions

Why are all properties marked required by default?
A single JSON example has all keys present, so they all look required. Disable "Mark all properties required" if you know some keys are optional, then remove specific keys from the required array manually for fine control.
Which draft should I choose?
Draft 2020-12 is the latest official version. Draft-07 is older but extremely widely supported — choose it if your downstream tool predates 2020 (e.g. older OpenAPI versions).
How does it handle arrays with mixed types?
For arrays where every element has the same shape, items is a single schema. For arrays of differently-shaped objects, the tool merges them: properties are union, and a key is required only if present in every element.
Does this generate $defs or $ref for reused shapes?
Not yet — every nested object is inlined. For complex schemas with reuse, post-process with a deduplication tool.
Does this send my JSON anywhere?
No. All generation happens locally in your browser.