JSON Schema Generator

Automatically generate a JSON Schema (Draft-07) from any sample JSON. Paste your JSON and get a valid schema instantly — no signup required.

Indentation:

Input JSON

Generated Schema

Your JSON Schema will appear here

Share this tool

Help others discover JSON Schema Generator

About JSON Schema Generator

How It Works

  • Paste or type any valid JSON in the left panel
  • The tool recursively analyses every key and value
  • Types are inferred: string, number, integer, boolean, object, array, null
  • All present keys are listed in the "required" array
  • The resulting Draft-07 schema is shown on the right

Common Use Cases

  • Bootstrapping API documentation and OpenAPI schemas
  • Validating JSON payloads in backend services
  • Generating TypeScript types via tools like json-schema-to-typescript
  • Creating strict data contracts between microservices
  • Documenting configuration file formats

Frequently Asked Questions

What is a JSON Schema?

A JSON Schema is a vocabulary that allows you to annotate and validate JSON documents. It describes the structure, types, and constraints of your JSON data, making it easier to validate inputs, generate documentation, and share data contracts between services.

What JSON Schema draft does this tool generate?

This tool generates JSON Schema Draft-07, which is the most widely supported version. Draft-07 is compatible with the majority of validators, editors, and API tools in use today, including VS Code, Postman, and OpenAPI 3.x.

How does the schema inference work?

The tool recursively inspects each value in your JSON. For every key it determines the JSON type (string, number, integer, boolean, array, object, or null), collects all unique keys found in objects, and marks them as required. Array item types are inferred from the first element. No data is sent to a server — everything runs in your browser.

Are all keys marked as required?

By default, every key present in the sample JSON is added to the "required" array. If your real data can have optional fields, simply remove those keys from the required array in the generated schema before using it.

What happens with null values?

When a value is null in the sample JSON, the tool generates a type of "null". If the field can hold other types as well, you should manually change the type to an array such as ["string", "null"] after generating the schema.

Can I generate a schema from a JSON array at the root level?

Yes. If your JSON is a top-level array, the generated schema will have type "array" with an "items" sub-schema inferred from the first element. This correctly models collections of uniform objects.

Is my JSON data sent to a server?

No. All processing happens entirely in your browser using client-side JavaScript. Your JSON is never transmitted to our servers, so sensitive data remains private.

Can I use the generated schema in OpenAPI / Swagger specs?

Yes. OpenAPI 3.x uses a superset of JSON Schema Draft-07, so the output of this tool can be pasted directly into the "schema" section of an OpenAPI component or inline request body definition with only minor adjustments (e.g. adding example fields).

What if my JSON has deeply nested objects?

The tool fully supports arbitrarily nested JSON structures. Each nested object gets its own "properties" block with correct type annotations, and nesting depth has no hard limit other than browser stack size (practically unlimited for real-world data).

What is the difference between "number" and "integer" in JSON Schema?

JSON Schema distinguishes between "integer" (whole numbers like 1, 42, -7) and "number" (any numeric value including decimals like 3.14). This tool automatically uses "integer" when the sampled value has no fractional part, and "number" otherwise.

Can I customize the schema after generating it?

Absolutely. The output is plain editable text. Common customizations include adding "description" fields, tightening string constraints with "minLength"/"maxLength" or "pattern", adding "enum" arrays for fixed values, and adjusting the "required" list.

What does the "additionalProperties: false" option do?

When enabled, "additionalProperties: false" is added to every object in the schema. This tells validators to reject any key that is not explicitly listed in "properties". It is useful for strict API contracts but should be disabled if your objects can have arbitrary extra keys.

Share ToolsZone

Help others discover these free tools!

Share this page

JSON Schema Generator — Infer Schema from JSON Online