Cryonel

JSON Schema Generator

Paste a sample JSON value to generate a matching JSON Schema (draft-07) — types, nested objects, arrays, and required fields inferred from what's present.

How to use it

Paste a representative JSON sample and click Generate. Numbers without a decimal point are typed as integer; every key observed on an object is listed under required, since a single sample can't tell which fields are truly optional. Check the result against your JSON Schema Validator if you're not sure it's valid.

Treat inference as a starting point

A JSON sample shows values that happened once; it does not describe every valid future document. The generator can infer object, array, string, number, integer, boolean, and null shapes, then nest those shapes to match the sample. It cannot know business rules such as minimum lengths, numeric ranges, formats, descriptions, defaults, conditional requirements, or whether a field omitted from another response is optional. Review the output before using it as a contract.

Required properties need human review

Every property visible in the sample is added to required. That conservative choice catches missing data when the sample represents the complete contract, but it overstates requirements when the payload is only one example. Remove truly optional names from required while leaving their schemas under properties. A required property may still accept null if its schema allows null; presence and nullability are separate decisions.

Arrays reveal only observed items

A non-empty array lets the generator inspect its elements. Mixed observed shapes produce an anyOf starting point, while an empty array provides no evidence about item type. Real arrays may contain more variants than one payload exposes. Collect representative examples from successful, empty, error, and edge-case responses, then merge the intended rules manually instead of assuming the first record is complete.

Add contract meaning after generation

Useful production schemas often need minLength, pattern, format, enum, numeric boundaries, array limits, reusable definitions, and a deliberate additionalProperties policy. Add titles and descriptions that explain domain meaning rather than restating field names. Avoid deriving sensitive examples or secrets into documentation. Choose the schema draft and vocabulary supported by the validators, code generators, API gateway, and documentation tools in your actual pipeline.

Validate several positive and negative examples

Send the generated result to JSON Schema Validator, then test more than the original sample. Positive cases should cover optional fields and boundary values. Negative cases should omit required properties, use wrong types, exceed limits, and include unexpected fields when those should be rejected. A schema that accepts only its generating sample is not yet a useful interoperability contract.

Evolve schemas deliberately

Once consumers depend on a schema, changing it can be breaking even when the new version validates a fresh sample. Adding a required property, narrowing a type or range, removing an enum value, or forbidding previously accepted properties can reject existing payloads. Review schema changes with JSON Diff and test representative consumer fixtures. Generation and editing happen locally in this tab; the sample is not uploaded to Cryonel.

Frequently Asked Questions

What if an array has mixed element types?

The generated items schema becomes an anyOf listing each distinct element schema observed.

Why are all my object fields marked required?

Inference works from a single sample, so every key that was present in your input is included in required. Remove any that are actually optional by hand.

Which JSON Schema draft does this target?

Draft-07 ($schema: "http://json-schema.org/draft-07/schema#"), the version most widely supported by validators and code generators.

Related Tools