JSON Schema Generator

Infer a JSON Schema (draft-07) from a sample JSON object β€” instantly

Schema will appear here…

About this tool

The JSON Schema Generator infers a JSON Schema (draft-07) directly from a sample JSON object β€” no manual schema authoring required. It detects types for every field, including nested objects and arrays, and marks fields present in your sample as required by default. JSON Schema is the standard way to formally describe the shape of JSON data β€” used for API request/response validation, form generation, and configuration file validation across the JavaScript, Python, and Java ecosystems alike. Generating one from a real example is far faster than hand-writing the schema from a specification document.

When to use it

  • β†’Generating a starting JSON Schema from a real API response to use with a validation library (Ajv, jsonschema, etc.)
  • β†’Documenting the expected shape of a request or response body for API documentation
  • β†’Creating a schema to validate configuration files against before your application loads them
  • β†’Producing a schema other tools (form generators, mock servers) can consume from real example data

Tips

  • β—†Generated schemas mark every field present in your sample as required β€” uncheck 'Mark all present fields as required' if your sample happens to have every optional field filled in.
  • β—†Arrays with mixed-type elements produce a schema based on the first element's shape β€” review array schemas manually if your data has genuinely heterogeneous array contents.
  • β—†A generated schema is a draft, not a final spec β€” add format validators (email, date-time, uri) and value constraints (minimum, maxLength, pattern) by hand for fields that need them.

Frequently asked questions

Can a schema generated from one example be trusted as complete?

Treat it as a solid first draft, not a final schema. It reflects only the fields and types present in the one sample you provided β€” if a field is sometimes null, sometimes absent, or sometimes a different type across different real responses, the generated schema won't capture that variation. Validate against several real examples and adjust the schema for fields you know vary.

What is JSON Schema actually used for?

JSON Schema formally describes what valid JSON should look like β€” required fields, types, formats, and constraints. It's used to validate API requests before processing them, validate API responses in tests, generate documentation and client SDKs, auto-generate form UIs, and validate configuration files at load time. Libraries like Ajv (JavaScript), jsonschema (Python), and everit-org/json-schema (Java) all validate against the same standard.

Why does the schema say type: 'integer' for some numbers and 'number' for others?

JSON Schema draft-07 distinguishes whole numbers (integer) from numbers with a fractional component (number). The generator checks each numeric value in your sample: 30 produces integer, 30.5 produces number. If a field is sometimes a whole number and sometimes has decimals across different real responses, use number in the schema since it's the broader type that also accepts integers.

Related tools

πŸ₯· ToolNinja