FC

📐 JSON Schema Generator

Runs entirely in your browser - no data sent to server

Output appears here...
Complete Guide

📊 Key Data Points

Draft-07

Supported by ajv, jsonschema (Python), VS Code, and most validators

Auto-required

All observed fields marked required by default — edit to match actual API contracts

Recursive

Handles arbitrarily deep nesting — generates schemas for objects within objects

JSON Schema Generator — Auto-Generate from Sample JSON -- Complete USA Guide 2026

JSON Schema validates API response structure — ensuring required fields exist, types are correct, and values match patterns. Writing schema by hand for complex nested responses is slow and error-prone. This generator infers a Draft-07 schema from your sample JSON automatically.

Runs in your browser.

**Long-tail searches answered here:** auto generate JSON schema from example online free, JSON schema draft-7 generator from sample data, convert JSON to JSON schema browser tool.

Validate your JSON first with JSON Formatter.

🔬 How This Calculator Works

Traverses the sample JSON and records the type of every value. Objects produce type object with properties and required arrays. Arrays produce type array with items. Strings become type string, numbers become type number (integers get type integer), booleans and nulls are typed accordingly. All observed keys are marked required by default — remove entries for genuinely optional fields. Output is valid JSON Schema Draft-07.

✅ What You Can Calculate

Instant schema from sample

Paste a sample API response and get a Draft-07 schema in seconds — all properties, nested objects, and array item types covered automatically.

Required fields detection

All fields present in the sample are marked required. Strong starting point — remove required entries for optional fields.

Recursive nesting

Generates correct nested schemas for arbitrarily deep objects — a three-level nested API response produces a properly nested schema at each level.

Draft-07 compatible

Works with ajv (Node.js), jsonschema (Python), and VS Code — the most widely-supported JSON Schema version.

🎯 Real Scenarios & Use Cases

API contract documentation

Generate a schema from a sample response as the starting point for your OpenAPI/Swagger spec. Add descriptions, examples, and additional validation rules from there.

Runtime validation

Paste the schema into your ajv setup in Node.js or jsonschema in Python. Catch invalid API responses at runtime rather than during data processing.

TypeScript type generation

Tools like json-schema-to-typescript and quicktype convert JSON Schema to TypeScript interfaces. Generate schema here, then feed to those tools.

Test fixture validation

Generate schemas from test fixture JSON and use them to validate that API responses in integration tests match the expected structure.

💡 Pro Tips for Accurate Results

Use multiple samples for optional fields. The generator marks all observed fields required. For optional fields, generate schemas from multiple samples and manually remove the optional keys from the required array.

Array item schemas from first element. The item schema is inferred from the first array element only. If your array contains mixed types, add a oneOf manually.

Add descriptions for documentation quality. The generated schema lacks descriptions. Add description properties to each field for OpenAPI-quality schemas.

Validate the schema itself. The output is JSON — paste it into JSON Formatter after manual edits to verify it is still valid JSON.

🔗 Use These Together

🏁 Bottom Line

Manual JSON Schema authoring is slow and error-prone. This generator gives a correct starting point from sample data — all fields, types, and nesting covered. Edit to add descriptions and mark optional fields. For the complete validation workflow: generate here, query with JSONPath Tester, and create test data with Fake Data Generator.

What is JSON Schema and what is it used for?

JSON Schema validates, annotates, and documents JSON documents. It defines which properties exist, their types, which are required, min/max values, string patterns, and nested object schemas. Used in: API request/response validation (Fastify, Express-validator, OpenAPI spec), form validation, MongoDB schema validation, and auto-generated documentation. The auto-generated schema from this tool is a starting point — refine by adding descriptions, examples, and additional constraints.

What is the difference between JSON Schema draft-07, 2019-09, and 2020-12?

Draft-07 (2018) is the most widely supported — added if/then/else conditionals. Draft-2019-09 added $anchor, $recursiveRef, and unevaluatedProperties. Draft-2020-12 changed $ref behavior and added prefixItems for arrays. For maximum compatibility, use draft-07. For modern validators (ajv 8+): draft-2020-12 is current. The $schema keyword declares which version a schema uses.

How do I add validation constraints to an auto-generated schema?

The generator infers basic types. Refine with: strings — minLength, maxLength, pattern (regex), format (email, uri, date-time). Numbers — minimum, maximum, multipleOf. Arrays — minItems, maxItems, uniqueItems: true. Objects — additionalProperties: false (reject unknown keys). Enums — replace type with enum: [allowed, values]. The generated schema marks observed required fields — adjust based on actual business logic.

How do I validate API requests with JSON Schema in Node.js?

Most popular validator is ajv: const ajv = new Ajv(); const validate = ajv.compile(schema); const valid = validate(data); if (!valid) console.log(validate.errors). For Express: use express-ajv-swagger-validation. For Fastify: natively uses ajv for route schema validation — define schema in route options and Fastify validates body, params, and query automatically. For Python: jsonschema library.

What is the difference between additionalProperties: false and unevaluatedProperties: false?

additionalProperties: false rejects any property not listed in properties or patternProperties at the same schema level. It does not account for properties defined in allOf/anyOf/oneOf. unevaluatedProperties: false (draft-2019-09+) is stricter — also considers properties defined in all applicator keywords. For most schemas without complex combiners, additionalProperties: false is sufficient and more widely supported.

How do I represent a field that can be string or null?

Draft-07: { "type": ["string", "null"] } as an array of types. Or use oneOf: [{"type": "string"}, {"type": "null"}]. In OpenAPI 3.1 (aligned with JSON Schema 2020-12): { "type": ["string", "null"] } is the correct form — nullable: true is an OpenAPI 3.0 extension not standard JSON Schema. The auto-generated schema infers nullable if your sample data contains null values.

What other JSON tools pair with the Schema Generator?

The JSON Formatter validates and formats JSON before feeding it to the schema generator. The JSONPath Tester queries JSON documents against the schema structure. The JSON to CSV tool exports validated data. The Diff Checker compares two schema versions when you update your data model. The curl Builder tests API endpoints that should conform to your schema. All are in the Dev Tools section.