JSON Schema Generator

Infer a JSON Schema (draft-07) from a sample JSON object, or validate JSON against an existing schema

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. A Validate mode goes the other direction: paste any JSON Schema (generated here or written by hand) alongside a JSON payload, and see exactly which fields fail and why β€” a wrong type, a missing required field, an out-of-range value, or a value outside an enum list β€” with the exact path to each problem field.

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
  • β†’Checking a sample payload against a schema before writing it into automated tests
  • β†’Debugging why a real API response doesn't validate against its documented schema

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.
  • β—†'Detect string formats' adds a format keyword (email, date-time, date, uri, uuid) when a sample string matches one of those shapes β€” review it, since a format match on your specific sample isn't a guarantee every value in production will match the same pattern.
  • β—†A generated schema is a draft, not a final spec β€” add value constraints (minimum, maxLength, pattern) by hand for fields that need them beyond what format detection covers.
  • β—†In Validate mode, a type mismatch on a field stops that field's checks there β€” a wrong-type value can't meaningfully be checked for a missing nested property, for example, so the tool reports the type error and moves on rather than cascading confusing follow-up errors.

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.

Does the Validate mode support the full JSON Schema specification?

It covers the subset most real-world schemas actually use β€” type, properties, required, items, enum, and the min/max numeric and string-length keywords. It doesn't implement $ref references, allOf/oneOf/anyOf composition, pattern (regex), or format validators β€” for those, use a full validation library like Ajv in your actual codebase; this tool is for a quick manual check, not a drop-in replacement for one.

Related tools

πŸ₯· ToolNinja