Draft a data contract
Start with an API response or exchange file, then compare the proposed structure with business documentation. Add constraints the sample cannot prove.
Analyze a JSON document and infer types, properties, arrays and required fields automatically.
Draft JSON Schema from a representative JSON document. The generator identifies types, nested objects, lists and observed properties to describe a reusable structure targeting draft 2020-12. Output is a proposal to review, not automatic discovery of every API rule. No document is uploaded to an inference service: your browser analyzes the sample and displays a JSON schema file to inspect, copy or export.
Strings become string, booleans boolean and null becomes null. Observed integers are distinguished from other numbers. Objects produce properties; arrays infer items from every supplied entry rather than only the first. Type variations can be represented using anyOf.
Properties are combined across objects in the same array. A key missing from some objects is excluded from required; a consistently present key is included. This rule only reflects samples. If the sole response includes a field that is optional in the real contract, the generator cannot infer that omission is possible.
Generated objects use additionalProperties: false, rejecting unobserved keys even when your application would accept them. Review this policy before validating future responses. An empty array provides no information about future elements, so their schema stays open instead of inventing an item type.
Inference does not invent email formats, regex constraints, numeric bounds or exhaustive allowed values. A date remains a string. Observing 1 proves neither minimum: 1 nor const: 1. Numbers use the browser’s representation; keep large identifiers as strings when that is the contract’s representation.
Paste valid JSON with the complete structure. Prefer anonymized data showing relevant shapes rather than large volumes of repeated values.
Review inferred types, required entries and closed objects. A null value is different from an absent property.
Add justified formats or bounds and test valid and invalid examples before integration. Downloads contain a JSON schema, not a TypeScript module.
Start with an API response or exchange file, then compare the proposed structure with business documentation. Add constraints the sample cannot prove.
Include omitted fields, present fields and nulls to distinguish required properties from allowed types. Varied samples provide a more representative starting point.
Use the schema with a validator supporting its draft and keywords. Generation does not install automatic checks in your application.
id becomes integer and active boolean. Both are required because they appear in the observed object; additionalProperties rejects extra keys.
Input
{"id":1,"active":true}Result
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"active": {
"type": "boolean"
}
},
"required": [
"id",
"active"
],
"additionalProperties": false
}id appears in both objects and remains required. name appears only in the second, making it a known but optional property.
Input
[{"id":1},{"id":2,"name":"Ada"}]Result
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
},
"required": [
"id"
],
"additionalProperties": false
}
}No. Every supplied entry contributes. Object properties are combined and observed omissions affect required. This still analyzes samples, not unknown future data.
It was never absent from the relevant sample group. Remove it from required according to the real contract or add a representative object that omits it.
Generated objects are closed with additionalProperties: false. Change that rule when your policy permits new properties; make the choice explicitly before validating evolving data.
No. It describes observed shapes and needs business review. Add relevant constraints, then run a validator supporting the draft and keywords you actually use.
Related tools
Tools similar or complementary to this one.
Validate a JSON document against a schema and locate every error precisely.
Generate TypeScript interfaces, types, Zod schemas, or JSON Schema from sample JSON.
Format, minify, and validate JSON to make it easier to read or more compact.
Understand ISO 8601 week numbers, Unix timestamps in seconds or milliseconds, and the difference between human-readable dates and technical time values.