← Hashito System Home 日本語 Tools Blog
Generate
What is supported
Builds a JSON Schema (draft 2020-12) from sample JSON. Objects, arrays, strings, numbers (integers and decimals are distinguished), booleans and null are supported, at any nesting depth. Arrays are inspected element by element and differing types are combined with anyOf.

About generating a JSON Schema

How to use

Paste sample JSON on the left and press "Generate schema" to get a JSON Schema (draft 2020-12) on the right. This is useful for drafting a schema from an example API response, for starting validation of a config file, or for having a machine state the shape of your test data. Paste an array and the result is one schema derived from every element.

How required and format are decided

With "Mark every key required" on, every key seen in the sample becomes required. Starting strict and removing the optional keys afterwards is usually faster than the other way round. Turn it off for data with many optional fields. "Infer string format" looks only for date, date-time, email and uri. Strings that match none of them get no format, because guessing would add a constraint the data does not support.

What it cannot do

Shapes that never appear in the sample are unknown to it. Minimum and maximum values, enum, pattern and string length cannot be decided from one sample either, so they are not emitted. Treat the output as a draft, not as the specification itself.

Frequently Asked Questions

Can I use the generated schema as is?

It is valid and ready to run, but it only encodes the facts present in your sample. A schema describes the shape that fits this data, not the contract of your API, so review it before using it. Pay particular attention to required and to any field where the sample showed only one kind of value, and check them against the real range of your data.

What if array elements have different types?

That is fine. Every element is inspected, not just the first one, and differing types are combined with anyOf. Objects are merged property by property, and required keeps only the keys that were present in every element. Integers mixed with decimals are combined as number.

Is my data sent to a server?

No. Generation runs entirely in JavaScript in your browser. The JSON you paste is never sent to or stored on a server.