CalcCafe

JSON to JSON Schema

Paste a JSON sample and get a draft-07 JSON Schema with inferred types, properties, required fields, and nested array/object structures.

Example

Given this JSON input:

{ "id": 7, "name": "Ada", "tags": ["x", "y"] }

the tool infers this draft-07 schema:

{
 "$schema": "http://json-schema.org/draft-07/schema#",
 "type": "object",
 "properties": {
  "id": { "type": "integer" },
  "name": { "type": "string" },
  "tags": {
   "type": "array",
   "items": { "type": "string" }
  }
 },
 "required": ["id", "name", "tags"]
}

How it works

It parses your JSON and walks every value, mapping each to a schema type (string, integer, number, boolean, null, array, object) and recursing into nested objects and array items. Object keys present in the sample become "required", and arrays infer their item schema (merging types if items differ).

Good to know

The JSON to JSON Schema tool turns a single example of your JSON data into a draft-07 JSON Schema, the standard format used to validate that incoming data has the right shape. It reads each value, decides whether it's a string, integer, number, boolean, null, array, or object, and recurses into nested objects and array items so even deeply structured payloads get a complete schema. It's aimed at backend and API developers, integration engineers, and anyone who needs a validation contract but doesn't want to hand-write one from scratch.

Reach for it when you have a sample API response, a config file, or a webhook payload and want a starting schema to plug into a validator (Ajv, python-jsonschema, etc.), an OpenAPI definition, or a CI check. Because everything runs in your browser, you can safely paste sensitive production samples without anything being uploaded.

To read the output: type tells you the inferred type of each value; properties lists every object key with its own nested schema; required lists keys that appeared in your sample; and an array's items describes the shape of its elements. When array elements disagree, you'll see a union like "type": ["integer", "string"] instead of a single type, which is your cue that the data is heterogeneous.

The most important caveat is that the schema reflects one example, not your whole dataset. A few practical things to adjust afterward:

Frequently asked questions

Why are all my fields marked as required?
The schema is inferred from a single sample, so every key present is treated as required. Remove keys from the generated "required" array for fields that are optional in your real data.
How are arrays with mixed types handled?
If all array elements share one inferred schema, the "items" schema uses it directly. If elements differ, the item type becomes a union array, e.g. "type": ["integer", "string"].
Is my data uploaded anywhere?
No — it runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.

People also ask

What is JSON Schema draft-07?
Draft-07 is a widely supported version of the JSON Schema specification, a vocabulary for describing and validating the structure of JSON data. It is identified by the $schema value http://json-schema.org/draft-07/schema# and is compatible with most popular validators.
How do I validate JSON against the generated schema?
Save the generated schema to a file and pass it, along with your JSON data, to a JSON Schema validator such as Ajv in JavaScript or jsonschema in Python. The validator reports whether the data conforms and lists any errors.
Why does a null value produce "type": "null" instead of a nullable field?
The tool infers types literally from the sample, so a value of null is recorded as the null type. To allow a field to be either a value or null, change it to a union such as "type": ["string", "null"] after generating the schema.
How is an empty array handled?
An empty array produces an array schema with no item type constraint (an empty items object), because there are no elements to infer a type from. Include at least one example element if you want the item type captured.
What is the difference between the integer and number types here?
A whole number like 7 is inferred as integer, while a value with a decimal part like 4.8 is inferred as number. If a field can hold both, you may want to widen it to number, which also accepts integers.
Can I convert JSON Schema back into JSON data?
Not with this tool, which only goes from a JSON sample to a schema. Producing sample data from a schema is a separate task often handled by JSON Schema faker or mock-data generators.
Does the order of keys in my JSON affect the schema?
Key order does not change validation, since JSON objects are unordered, but the generated properties and required entries generally follow the order keys appear in your sample. Validators ignore that order when checking data.
How are nested objects and arrays of objects represented?
Nested objects become their own object schemas under properties, with their own type, properties, and required lists. An array of objects produces an items schema describing the shared object structure, merging types when elements differ.

Related tools