Skip to main content
NyankoTools

JSON Schema Generator

Paste a JSON sample and get a matching JSON Schema. Useful as a starting point for validating API responses or data files. Objects inside arrays are merged into one schema, and keys found in only some items are left out of required. If you want type definitions instead, try the JSON to TypeScript Converter.

🔒 Runs in your browser · Your data is never sent to a server

Notes

  • The schema is inferred from the values in your sample. Constraints that are not visible in the sample (enums, length or numeric ranges, patterns) are not generated, so add them by hand to match your spec.
  • Only keys that appear in every object of the sample become required. With a single sample, keys that are really optional will also be marked required.
  • A number such as 1.0 is an integer in JSON, so it is typed as integer.
  • Formats are guessed from how values look (date, date-time, email, URL, UUID) and are added only when every value at that position has the same format.
  • An empty array has no known element type, so it gets no items keyword and accepts anything.

Glossary

JSON Schema

A specification for describing the structure of JSON data (keys, types, required fields) in JSON itself, so the data can be validated. It is used for API input checks and editor autocompletion of config files.

required

The list of keys an object must contain. Keys not listed here may be omitted.

additionalProperties

Controls whether keys not listed under properties are allowed. Set to false, data with undeclared keys is invalid.

format

An annotation for string formats such as date-time, email, uri, and uuid. Some validators also enforce it.

FAQ

What happens when objects in an array have different keys?

All objects in the array are merged into one schema. Every key is listed under properties, and only keys present in every object are marked required.

Can I use the generated schema in production as is?

It covers what can be inferred from the sample: types and structure. Enums, length or numeric ranges, and regex patterns cannot be guessed from a sample, so add them to match your spec first.

What is the difference between draft 2020-12, 2019-09, and 07?

For the keywords this tool emits (type, properties, required, items, format), the schema is identical across drafts; only the $schema value changes. Pick the draft your validator library supports.

How are values that can be null represented?

When a string and null appear at the same position, the type becomes an array such as "type": ["null", "string"].

Share this page

↑↓ Select Enter Open Esc Close