JSON Schema Generator & Validator
Generate a JSON Schema from a sample or validate a JSON document against one, right in your browser. Your data never leaves your device.
Schema generation and Ajv validation run locally in your browser, so your JSON sample, schema and document are never uploaded.
Need TypeScript types instead? Try JSON to TypeScript.
About JSON Schema Generator & Validator
This JSON Schema generator turns a JSON sample into a ready-to-use JSON Schema, and the built-in validator checks any JSON document against a schema you provide. In Generate mode it walks your sample, infers types for objects, arrays, strings, numbers, booleans and null, unifies array items, and can mark every property required, set additionalProperties to false, and detect string formats like email, date, date-time, uri and uuid. Pick draft-07 or 2020-12 for the output. In Validate mode it runs Ajv with allErrors and ajv-formats, then lists each failure with its instance path and message. It is built for API developers, backend engineers and anyone defining or testing JSON contracts. Everything runs in your browser, so the sample and schema you paste stay on your device.
Features
- Infers a JSON Schema from a pasted JSON sample with correct types for objects, arrays, strings, numbers, integers, booleans and null
- Unifies array elements into one items schema and emits items:{} for empty arrays
- Toggle to mark every property as required, per object
- Toggle additionalProperties:false to lock objects down to known keys
- Optional string-format inference for email, date, date-time, uri and uuid values
- Choose draft-07 or 2020-12 output, which sets the $schema dialect
- Validate any JSON document against a schema using Ajv with allErrors and ajv-formats
- Copy the generated schema or download it as schema.json
How to use the JSON Schema Generator & Validator
- Choose Generate to build a schema, or Validate to check a document.
- In Generate, paste a JSON sample and toggle required, additionalProperties and format options.
- Pick draft-07 or 2020-12, then copy or download the resulting schema.json.
- In Validate, paste a JSON Schema on the left and a JSON document on the right.
- Read the valid/invalid badge and the list of errors, each with an instance path.
Example
Input
{
"id": 1,
"name": "Ada",
"email": "ada@example.com",
"tags": ["a", "b"]
}
Output
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"email": { "type": "string", "format": "email" },
"tags": { "type": "array", "items": { "type": "string" } }
},
"required": ["id", "name", "email", "tags"]
}
With required and format inference on, the sample yields a draft-07 schema.
Common errors & troubleshooting
- The generated schema has no required array even though every key is present. — Turn on "Mark all properties required"; by default the generator infers types only and leaves required empty so optional fields are not over-constrained.
- Validation reports "Invalid JSON Schema" before checking the document. — The schema pane itself must be a valid JSON object that Ajv can compile; fix the JSON syntax or unknown keywords in the schema first.
- A value that looks like a date is typed as a plain string. — Enable "Infer string formats". Detection is conservative and only adds a format when the sample value matches the email, date, date-time, uri or uuid pattern.
- A 2020-12 schema is rejected by a validator expecting draft-07. — Switch the draft selector to match your target. It only changes the $schema URL and the minor dialect differences between the two drafts.
Frequently asked questions
- Which JSON Schema draft does the generator use?
- Draft-07 by default, with an option for 2020-12. The choice sets the $schema dialect URL on the output and the minor differences between the drafts; the inferred structure is otherwise the same.
- How are required properties decided when generating a schema?
- By default no property is marked required, so the schema accepts partial objects. Turn on "Mark all properties required" to add every key of each object to its required array.
- How does the validator report errors?
- It runs Ajv with allErrors enabled, so you get every failure at once. Each error shows the JSON instance path (such as /items/0/id) and a human-readable message, including missing required keys and unexpected additional properties.
- Does the generator infer string formats like email or date?
- Yes, when "Infer string formats" is on. It checks sample string values against patterns for email, date, date-time, uri and uuid and adds the matching format keyword; values that match none stay as plain strings.
- How does it infer the schema for arrays?
- It merges the schemas of all array elements into a single items schema. Mixed object elements are merged property-by-property, a key missing from any element drops out of required, and an empty array becomes items:{}.
- Is my JSON sample or schema uploaded anywhere?
- No. Generation and validation, including Ajv, run entirely in your browser, so the sample, schema and document you paste are processed locally and stay on your device.
Related tools
- JSON Formatter — Beautify, minify and validate JSON with error locations.
- JSON to TypeScript — Generate TypeScript interfaces from a JSON sample.
- JSON Viewer — Text + collapsible tree viewer with expand/collapse and node paths.
- JSON Diff — Compare two JSON documents and see a structural, key-order-independent diff.
- JSON to Code — Generate Go, Rust, Python, Java, Kotlin, C# and TypeScript types from JSON.
- OpenAPI / Swagger Formatter — Format and validate OpenAPI / Swagger specs (JSON or YAML) and count paths and operations.
All ArrayKit tools