Schema will appear here
Paste JSON and click Generate Schema// infer draft-07 schema from any json sample
Instantly generate a JSON Schema draft-07 from any sample JSON object. Infer types, required fields, nested objects, and array schemas online free.
Schema will appear here
Paste JSON and click Generate SchemaPaste any valid JSON object or array into the input panel. Use the Sample button to try an example.
Choose schema draft version, how required fields are marked, and whether to allow additional properties.
Click Generate Schema. Copy the output or download it as a .json file for immediate use.
A JSON Schema Generator infers a valid draft-07 (or later) schema document from a sample JSON value. It examines each key's type, detects common formats like email and date-time, handles deeply nested objects and arrays, and marks fields as required โ producing a schema you can plug straight into validators like AJV, FastAPI, or Pydantic.
Draft-07 is a widely supported version of the JSON Schema specification that adds features like if/then/else, readOnly, and writeOnly. It is the default schema dialect used by many validators including AJV, and is supported natively in VS Code for IDE completion.
Yes. The output is a valid draft-07 schema you can pass directly to AJV. Install AJV via npm, call ajv.compile(schema), then validate(data). The additionalProperties: false option (default) will reject any key not listed in the schema.
The generator inspects the first element of each array to determine the items schema. If the array contains objects, it recurses into that object to build a full nested schema. Empty arrays result in an items: {} (any type allowed).
When "Infer formats" is enabled, the tool tests string values against common patterns and attaches a format keyword for: email, uri, date, time, date-time, ipv4, ipv6, and uuid.
Yes. When a value is null, the generator produces "type": ["string", "null"] (or the inferred type plus null) to represent nullable fields correctly under draft-07 semantics. In 2019-09 and later, it uses oneOf with a null branch.
OpenAPI 3.0 uses a subset of JSON Schema draft-04 with some draft-07 additions. Most generated schemas are compatible, but OpenAPI does not support $schema, if/then, or certain keywords. Use the Download button and adjust nullable: true if needed.
No. All schema inference runs entirely in your browser using JavaScript. Your JSON never leaves your machine โ there is no server-side processing, no logging, and no data retention.
The generator inspects the first array element. If your array genuinely contains mixed types, you can manually edit the downloaded schema to use "items": {"oneOf": [...]}. The visual tree view shows what was inferred so you can spot mixed arrays easily.
A JSON Schema Generator is a tool that automatically derives a formal schema document from a concrete JSON sample. Instead of hand-writing every type annotation, required array, and nested object definition, you provide one example payload and the generator infers the structure for you. The result is a valid JSON Schema document โ most commonly targeting draft-07 โ that you can immediately use with validators, code generators, documentation tools, and API frameworks.
๐ก Looking for premium web development assets? MonsterONE offers unlimited downloads of templates, UI kits, and developer assets โ worth checking out.
JSON Schema provides a vocabulary to describe the structure, content, and semantics of JSON data. Adopting it brings several practical benefits to API development:
$schema references and provide inline completions for JSON configuration files.json-schema-to-ts, quicktype, and datamodel-code-generator can turn a schema into TypeScript interfaces, Python Pydantic models, Go structs, and more.JSON Schema has evolved through several draft versions. Draft-07 (published 2018) remains the most widely implemented version across the ecosystem. It introduced the if, then, else keywords for conditional schemas, readOnly and writeOnly annotations, and the $comment keyword for human-readable notes.
Draft 2019-09 brought recursive references ($recursiveRef), vocabularies, and unevaluatedProperties. Draft 2020-12 cleaned up the spec further and added prefixItems for tuple validation. For most use cases, draft-07 is the safest choice due to near-universal validator support.
The inference engine in this tool uses the following logic for each JSON value:
{"type": "null"}{"type": "boolean"}{"type": "integer"}{"type": "number"}{"type": "string"}, optionally with format if a pattern matches (email, uri, date-time, uuid, ipv4โฆ){"type": "array", "items": <schema of first element>}{"type": "object", "properties": {...}, "required": [...], "additionalProperties": false}For nested objects, the engine recurses. The depth counter in the stats bar shows how deeply nested your sample is, which is useful for spotting unexpectedly complex payloads.
A common workflow for API developers:
required array to reflect which fields are truly mandatory vs. optional..json file and commit it to your repository under schemas/.ajv.compile(require('./schemas/response.json')).json-schema-to-ts or quicktype in CI to regenerate TypeScript types from the schema automatically.Inferred schemas are a starting point. To make them production-ready, consider adding:
minLength / maxLength for string fieldsminimum / maximum for numeric rangesenum for fields with a fixed set of allowed valuespattern for custom string formats not covered by the standard keywordsdescription annotations on each property for documentation purposesdefault values where appropriateAlways validate the schema itself against the JSON Schema meta-schema before deploying to production. The JSON Schema Validator tool on this site can help with that step.
OpenAPI 3.0 and 3.1 embed JSON Schema for component definitions. After generating a schema here, copy the properties object into your OpenAPI YAML or JSON under components.schemas.YourModel. Note that OpenAPI 3.0 uses a dialect of draft-04 โ replace $schema with nothing (OpenAPI infers it) and use nullable: true instead of type: [T, null]. OpenAPI 3.1 fully supports draft 2020-12 and is more permissive.