JSON Schema Generator
Generate a JSON Schema from example JSON online. Arrays are merged into optional and nullable fields, and formats like date-time, email and uuid are detected.
Something not working, or missing a feature? Send feedback
About the JSON Schema Generator
The JSON Schema Generator writes a JSON Schema from an example document, so you do not have to type out every property by hand. Give it a real API response or config file and it describes each value's type, detects formats such as date-time, email, uri and uuid, and merges the items of arrays, making keys optional or nullable when only some items have them.
Conversion happens in your browser, so your files and records stay private.
How to use the JSON Schema Generator
- Paste example JSON, or open a .json file. An array of several records gives a better schema than a single one.
- Choose the draft: 2020-12 for current validators, Draft 7 for older tools and OpenAPI 3.0-era projects.
- Decide whether keys present everywhere are required, whether extra keys are rejected and whether string formats are detected.
- Copy or download schema.json, then tighten it by hand with enums, ranges and patterns that one example cannot show.
Examples
Input
[
{ "id": 1, "email": "[email protected]", "plan": "pro", "trialEnds": null },
{ "id": 2, "email": "[email protected]", "plan": "free", "trialEnds": "2026-11-01T00:00:00Z", "referrer": "blog" }
]Result
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"email": {
"type": "string",
"format": "email"
},
"plan": {
"type": "string"
},
"trialEnds": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"referrer": {
"type": "string"
}
},
"required": [
"id",
"email",
"plan",
"trialEnds"
]
}
}referrer is optional because only one record has it, and trialEnds allows null because one record has null.
Input
{ "name": "devtoolry", "port": 8080, "debug": false }Result
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Config",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"port": {
"type": "integer"
},
"debug": {
"type": "boolean"
}
},
"required": [
"name",
"port",
"debug"
],
"additionalProperties": false
}No extra keys adds additionalProperties: false, so a misspelt key in the config fails validation.
Common mistakes
- Generating from a single record. With one example, every key looks required and every value has exactly one type. Paste an array of several real records so optional and nullable fields show up.
- Shipping the draft unchanged. An example cannot show limits or allowed values. Add enum, minimum, maxLength or pattern where the API documents them before using the schema for validation.
Works well with the JSON Schema Generator
- JSON Schema Validator: test documents against the generated schema.
- JSON to TypeScript: generate matching TypeScript types.
- JSON Formatter: tidy the example before generating.
Frequently asked questions
How does it decide which keys are required?
A key is required when it appears in every object seen at that position. With an array of records, a key that is missing from even one record becomes optional. Turn off Mark keys required to make everything optional.
Why is a field typed ["string", "null"]?
Because the example contains both a string and null for it. A union type in a type array is the standard way to describe a nullable value in JSON Schema; in OpenAPI 3.0 you would write nullable: true instead.
Can a schema from one example be trusted?
It describes the example, not every valid document. Numbers that happen to be whole become integer, a value that is always "pro" or "free" stays a plain string, and an empty array accepts any items. Review the schema and add minimum, maximum, enum, pattern and minItems rules where you know them.
Related tools
JSON to CSV
Convert JSON arrays to CSV online with automatic column detection, nested object flattening and custom delimiters. Open the result in Excel or Sheets.
CSV to JSON
Convert CSV to a JSON array online with header detection, type inference and delimiter auto-detection. Turn spreadsheet exports into data for APIs and code.
JSON to XML
Convert JSON to well-formed XML online with a configurable root element and attribute support. Validate the input and download the XML file.
XML to JSON
Convert XML to JSON online, keeping attributes and turning repeated elements into arrays. Malformed XML is reported with its location.
JSON to YAML
Convert JSON to clean, human-readable YAML online. Turn API responses and package files into config for Kubernetes, Docker Compose or CI pipelines.
YAML to JSON
Convert YAML documents to formatted JSON online with syntax validation. Errors are reported by line, so broken indentation is quick to find and fix.