JSON Developer Tool

JSON Schema Generator

Infer a Draft-07 JSON Schema from a real JSON sample for validation, docs, and API contracts.

JSON Schema (Draft-07) Output
Output will appear here

Infer a JSON Schema from a real JSON example

JSON Schema is used to validate API request/response bodies, document data contracts, and power form generation and IDE autocompletion. Writing one by hand is tedious — this tool infers a Draft-07 schema directly from a real JSON sample, so you get a solid starting point in seconds.

What the generator infers

  • Types: string, number, integer, boolean, null, object, and array, matched to JSON Schema's type system.
  • Object properties & required fields: Every key present in your sample is added to properties and listed as required, since it appeared in the example.
  • Array item types: Homogeneous arrays get a single items schema; arrays with mixed item shapes get an anyOf of the distinct shapes.
  • Examples: Scalar object properties include an example value taken straight from your input, which is useful in generated API docs.

Because inference is based on one sample, treat the required list as a starting point: remove any field you know is actually optional across other real payloads, and add constraints like minimum, maxLength, or enum by hand where they matter.

Typical use cases

  • API contract documentation: Generate a first-draft schema for an OpenAPI/Swagger spec from a real response.
  • Request validation: Feed the schema into a validator like Ajv (JavaScript), jsonschema (Python), or similar libraries in other languages.
  • Data contracts between teams: Give another team a concrete, machine-readable definition of a payload shape instead of a prose description.

New to JSON Schema? Start with Understanding JSON Schema: A Beginner's Guide.

Frequently Asked Questions

Draft-07, referenced via the $schema keyword. Draft-07 is widely supported by validators across most languages.
The generator marks every field present in your sample as required, since that's all it can infer from a single example. Review and relax the required array for fields that are genuinely optional in your real data.
No, it doesn't guess semantic formats such as format: "email" or format: "date-time", since that would risk being wrong. Add those manually where you know they apply.
Yes — paste a JSON array and the tool infers a schema whose items describes the shape of the records inside it.