Generate a JSON Schema from JSON

Paste a sample response and get a JSON Schema (draft 2020-12) to start a contract test from: property types, required keys, array item schemas merged across elements, and formats for dates, emails, UUIDs and URLs. It is a starting point inferred from one example, meant to be tightened by hand, not a specification.

What it infers

Integers and numbers are told apart, a field present in every array element is required while one present in some is optional, mixed types become a type list, and strings that all look like ISO dates, emails, UUIDs or http(s) URLs get the matching format.

What it cannot know

One example shows what was returned, not what may be returned: enums, ranges, nullable fields that happened to be set, and optional fields that happened to be present. Review required and additionalProperties before using the schema to fail a build.

Using it in a test

Validate every response from an endpoint against the schema with a validator such as Ajv or jsonschema. A schema test catches a renamed or retyped field that an assertion on two values would miss.

Other tools

All tools · Getting started guide · All 55 mock REST APIs

Last updated