Array mode:
Indent:
Sample JSON 0 B
Ready
0 nodes
Generated Schema draft-07
Generated JSON Schema will appear here...
0 chars
Features

A complete schema generator

📜 Draft-07 compliant

Output follows JSON Schema draft-07 conventions, using keywords like type, properties, required, items, and additionalProperties. Compatible with Ajv, jsonschema, and other modern validators.

🧠 Type inference

Strings, integers, floats, booleans, null, arrays, and objects are detected automatically. Integers and floats are distinguished so a value of 1 becomes "integer" while 1.5 becomes "number".

✅ Required fields

Optionally mark all observed properties as required (the default). Toggle the checkbox off to omit the required array, making every field optional from the schema's perspective.

🔀 Array modes

For arrays, choose first (use the first item's schema), all (merge all items into one schema), or tuple (positional schema with additionalItems: false).

🔒 Additional properties

Toggle whether objects allow properties not listed in the schema. Default is off (strict) — the schema rejects unknown keys. Turn it on for permissive, schema-as-documentation workflows.

✔️ Validation ready

Use the generated schema with the JSON Validator to check other JSON documents against the same structure. Perfect for API response validation and contract testing.

FAQ

Schema generation — common questions

What is JSON Schema?

JSON Schema is a vocabulary for annotating and validating JSON documents. A schema describes the expected structure: which fields are present, what types they hold, and what constraints (minimum, maximum, pattern, enum) they must satisfy.

It's widely used in API design (OpenAPI uses JSON Schema for request and response bodies), configuration validation, and form generation. A schema can also serve as living documentation for the shape of your data.

This tool generates a draft-07 schema automatically from a sample JSON value, so you don't have to write one by hand.

Which draft version is supported?

JSONLab generates draft-07 schemas, the most widely supported version today. The output uses keywords like $schema, type, properties, required, items, and additionalProperties — all standard draft-07.

The schema is compatible with popular validators including Ajv (JavaScript), jsonschema (Python), and json-schema-validator (Java). Just paste it into your validator's input.

Can I use the schema to validate other JSON?

Yes. Copy the generated schema and feed it to the JSON Validator, which supports schema-based validation against a subset of draft-07 keywords (type, required, properties, items, enum, minimum, maximum, minLength, maxLength, pattern, additionalProperties).

You can also use the schema in your own code: const Ajv = require('ajv'); const ajv = new Ajv(); const validate = ajv.compile(schema); const valid = validate(data); — and inspect validate.errors for failures.

How are arrays handled?

JSONLab offers three array modes via the toolbar. First uses the schema of the array's first element — fast and simple, ideal for homogeneous arrays. All merges schemas from every item into a single items schema, useful when items have varying shapes.

Tuple produces a positional schema: each array index gets its own schema, and additionalItems is set to false. This is the right choice for fixed-length arrays like [latitude, longitude] or RGB triples like [255, 128, 0].

What about optional fields?

By default, every property observed in the sample JSON is listed in the schema's required array. This is the strictest interpretation and works well when your sample represents the canonical shape of the data.

If your real data has optional fields, toggle Required off in the toolbar. The schema then omits the required array entirely, meaning every property becomes optional. You can hand-edit the schema afterward to mark only specific fields as required.

For richer optional/required control across multiple samples, generate schemas from each and merge them — the All items array mode does something similar for array elements.