JSON Schema Generator Online – Generate Schema from JSON

Generate and configure a reviewable JSON Schema from one value or multiple representative samples, including optional-field and type merging.

Runs locally
Ready to generate

Paste one valid JSON value to infer its current shape.

116 chars

Merge one or multiple samples, then choose a dialect, required-key policy, nullable behavior, whether object schemas accept extra properties, and optional string formats.

0 chars

JSON Schema generation guide

How to generate JSON Schema from sample data

Paste one valid JSON value, or switch to multiple-sample mode and provide a non-empty JSON array of representative values. VetaTool merges object fields, required-property evidence, array item shapes, nullability, and primitive types locally in your browser, then produces readable JSON Schema output for review. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • Single or multiple JSON sample inference
  • Cross-sample optional property detection
  • Object property inference
  • Configurable required field output
  • Configurable nullable type unions
  • Recursive additionalProperties control
  • Primitive JSON type inference
  • Nested array and object inference
  • Heterogeneous array anyOf output
  • Optional date-time, date, time, email, URI, and UUID format inference
  • Optional Draft 7 or Draft 2020-12 $schema declaration
  • Copy and .schema.json download actions
  • Browser-local processing

How to use

  1. Choose Single JSON value, or choose Multiple samples and paste a non-empty JSON array whose elements are samples.
  2. Choose dialect-neutral, Draft 7, or Draft 2020-12 output.
  3. Configure required keys, nullable values, additional object properties, and optional string format inference, then select Generate Schema.
  4. Review heterogeneous array anyOf entries, then copy or download the generated schema.

What the generator infers

Objects become schemas with properties based on every observed field. In multiple-sample mode, only fields present in every object sample remain required; optional fields stay in properties without being forced into required. Numbers, strings, booleans, null values, arrays, and nested objects are merged recursively.

Optional string format inference recognizes conservative date-time, date, time, email, absolute URI, and UUID syntax. Values that only resemble those formats remain ordinary strings.

Arrays with one repeated shape use a single items schema. Multiple samples merge array-item observations across every sample, while genuinely different item types use a deduplicated anyOf list so no observed shape is silently discarded.

Multiple samples improve evidence but do not reveal every business rule

One payload cannot prove whether a field is optional. Multiple representative samples provide stronger evidence: fields missing from any object sample become optional, observed numeric and null types are merged, and nested object or array variations are combined. Even then, the generated result remains a configurable starting point rather than a complete application contract.

  • Required includes every key in single-sample mode, but in multiple-sample mode includes only keys observed in every corresponding object; it can also be disabled entirely.
  • Nullable can preserve observed null values or allow null alongside every inferred value type.
  • Additional properties can remain allowed or be rejected recursively with additionalProperties: false.
  • String formats can remain disabled or be inferred only from complete standard syntax.
  • Empty arrays remain unconstrained because no item type was observed.

Configure contract strictness before exporting the schema

Required, nullable, additional-property, and string-format controls apply recursively to nested object properties and object schemas inside arrays. Single-sample defaults remain unchanged. In multiple-sample mode, required arrays reflect only fields present in every corresponding object sample, while observed type differences are merged conservatively.

Allow null everywhere uses JSON Schema type unions such as ["string", "null"]. Reject extra keys adds additionalProperties: false to every inferred object schema. Format inference adds only supported standard format annotations. These constructs work in dialect-neutral, Draft 7, and Draft 2020-12 output.

Infer standard string formats only when requested

Optionally infer standard string formats when values already use complete standard syntax. The generator can add date-time, date, time, email, uri, or uuid to string schemas, while malformed dates, local-looking emails, relative URLs, and descriptive strings stay unformatted.

Format inference describes lexical shape, not business intent. Review every inferred format before using the schema as an API or validation contract.

Choose dialect-neutral, Draft 7, or Draft 2020-12 output

Dialect-neutral output keeps the conservative shared subset without a $schema declaration. Draft 7 adds http://json-schema.org/draft-07/schema#, while Draft 2020-12 adds https://json-schema.org/draft/2020-12/schema. All three choices use the same required, nullable, and additional-property settings.

Generation runs locally in the browser, so API samples and configuration data are not sent to a schema service.

JSON Schema generation example

The generator infers required object properties, an integer identifier, a string name, and homogeneous string array items.

Sample JSON

{
  "id": 1,
  "name": "Ada",
  "tags": ["admin", "editor"]
}

Generated schema

{
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "name": { "type": "string" },
    "tags": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["id", "name", "tags"]
}

Common questions

Frequently asked questions

Does the generator choose a JSON Schema draft?

You can keep dialect-neutral output, select Draft 7, or select Draft 2020-12. The explicit options add the corresponding official $schema declaration without changing the inferred sample shape.

How does multiple-sample mode decide which fields are required?

In single-sample mode, every observed key is required because one payload provides no evidence that it is optional. In multiple-sample mode, a field is required only when it appears in every corresponding object sample. Change Required properties to None to omit required arrays entirely.

Can I control required, nullable, and additional properties?

Yes. Required can include all observed keys or none, Nullable can preserve observed null values or allow null for every inferred value, and Additional properties can remain allowed or add additionalProperties: false recursively.

How are mixed arrays represented?

Distinct observed item schemas are deduplicated and placed under items.anyOf. Repeated values with the same inferred shape produce one shared items schema.

Does the generator detect email, date, or URI formats?

Optionally. Set String formats to Infer standard formats to recognize conservative date-time, date, time, email, absolute URI, and UUID syntax. The default keeps every string unformatted, and near matches remain plain strings for review.

Are my sample JSON documents uploaded?

No. Parsing, sample merging, and schema inference run locally in your browser.

Debugging a specific JSON issue? Browse JSON troubleshooting.