JSON Schema Generator
Last updated:
Jsonic's JSON Schema Generator creates a JSON Schema from any JSON example in one click. Paste a JSON object or array, choose a draft version (draft-07 or 2020-12), and click Generate. The tool infers types for all fields — string, integer, number, boolean, null, array, and nested object — and detects common string formats including email, date, date-time, URI, and UUID. All detected keys are added to a required array by default (toggle the checkbox to disable). All processing runs in your browser with no data upload.
How to generate a JSON Schema from JSON
- Paste a representative JSON example into the left panel, or click Example to load a sample.
- Choose the draft version: draft-07 (most compatible) or 2020-12 (latest standard).
- Check or uncheck "required" to include or exclude the required array.
- Click Generate.
- Copy the generated JSON Schema and use it in your application, API docs, or validator.
FAQ
What is JSON Schema?
JSON Schema is a vocabulary for annotating and validating JSON documents. It defines the expected structure, data types, and constraints of a JSON value. It is used in API documentation (OpenAPI/Swagger), data validation, form generation, IDE autocompletion, and configuration file validation.
Which JSON Schema draft should I use?
Use draft-07 for maximum compatibility — it is supported by AJV, Python jsonschema, and most tools. Use 2020-12 for new projects that need the latest features like unevaluatedProperties, prefixItems, and the updated $ref behavior. Both produce equivalent output for common use cases.
How does the generator infer types?
The generator maps JSON value types to JSON Schema types: strings → "string", integers (whole numbers) → "integer", decimals → "number", true/false → "boolean", null → "null", arrays → "array" with an inferred "items" schema, and objects → "object" with "properties" and "required".
How are string formats detected?
The generator checks string values against common patterns: ISO 8601 date-time (e.g., "2024-01-15T10:30:00Z") → "date-time", ISO 8601 date (e.g., "2024-01-15") → "date", email addresses → "email", http/https URLs → "uri", UUID v4 pattern → "uuid". Unrecognized strings get no format annotation.
Are all keys marked as required?
By default, yes — all keys present in the example are added to the required array because they appear in the example. If some fields are optional in your real data, uncheck the "required" checkbox to generate a schema without it, then add required fields manually.
What if my JSON has inconsistent array items?
If an array contains items of different types (e.g., [1, "hello"]), the generator produces an anyOf schema with both types. If all items are the same type, it produces a single items schema.
How do I validate JSON against the generated schema?
Use the JSON Schema Validator tool on this site — paste the schema on the left and your JSON on the right, then click Validate. For production use, integrate AJV (JavaScript), jsonschema (Python), or org.everit.json.schema (Java).
Is the generated schema production-ready?
The generated schema is a starting point based on one example. For production APIs, review it to: add minLength/maxLength for strings, minimum/maximum for numbers, pattern for specific string formats, and adjust required fields to match your actual data contract.