Skip to content
Trexmi
Generator Ready

JSON Schema Generator

Generate a JSON Schema from sample JSON online. Choose Draft 4, 6, 7, 2019-09 or 2020-12, infer nested types and detect common string formats.

Nested object inference Array item inference Required property generation Email, URI, UUID, IP and date detection
Inference is based on sample values. Review required fields, unions, constraints, and formats before production use.
INPUT Sample JSON document *
0 chars0 words0 lines
Paste the source value for this specific transformation. Example: {"id":15,"name":"Ada","email":"ada@example.com","active":true,"tags":["api","json"],"profile":{"city":"Kyiv","created_at":"2026-08-04T12:30:00Z"}}
Generated JSON Schema Schema inferred from the supplied sample JSON.
About the tool

What JSON Schema Generator does

JSON Schema Generator converting JSON into a schema

JSON Schema Generator converts a representative JSON document into a structured schema that describes its objects, arrays, properties and primitive values. It is useful when an API already returns sample data but no formal contract exists, when a team needs a starting point for validation, or when test fixtures must be documented consistently.

The generator works entirely inside Trexmi and does not require an external API. Choose Draft 2020-12 for modern projects or select Draft 4, 6, 7 or 2019-09 when an existing validator requires an older vocabulary. The result is an inferred starting point rather than a substitute for domain review: optional properties, unions, numeric limits, regular-expression patterns and business rules cannot always be discovered from one example.

JSON Schema Generator table of contents

How to use

  1. Paste a valid JSON object or array into the source field. Use a realistic example containing the fields that your application normally sends.
  2. Select Draft 2020-12, 2019-09, Draft 7, Draft 6 or Draft 4. Keep format detection enabled when emails, UUIDs, URLs, IP addresses or dates should receive a format annotation.
  3. Choose whether observed object properties should be listed in required, then run the JSON Schema Generator.
  4. Review nested objects, array item types and detected formats. Add constraints such as minimum, pattern, enum or additionalProperties manually when your data contract needs them.
  5. Copy the generated schema and validate it with the JSON Schema Validator before using it in production.
Built for the task

Why use JSON Schema Generator?

Focused controls, predictable output, and a workflow designed around this exact transformation.

01

Infer nested JSON structures

Objects inside objects and arrays are converted recursively, preserving the shape of realistic API responses and configuration documents.

02

Support 5 major schema drafts

Generate output for Draft 4, 6, 7, 2019-09 or 2020-12 without rewriting the source JSON.

03

Detect useful string formats

Recognize common examples such as email, URI, UUID, IPv4, IPv6, date, time and date-time values when format detection is enabled.

04

Keep data private

The JSON is processed by the Trexmi tool endpoint and is not sent to a third-party AI or schema-generation service.

Useful answers

Questions about JSON Schema Generator

Practical details about input, output, privacy, limits, and the best way to use this tool.

Answer 01

What is a JSON Schema Generator?

A JSON Schema Generator examines sample JSON and creates a schema describing the observed types, properties, arrays and nested structures.

Answer 01

What is a JSON Schema Generator?

A JSON Schema Generator examines sample JSON and creates a schema describing the observed types, properties, arrays and nested structures.

Choosing the right JSON Schema draft

Draft 2020-12 is a strong default for new systems because it reflects the current JSON Schema vocabulary and modern array semantics. Draft 7 remains widely supported by libraries and API tooling. Draft 4 or 6 may be necessary for older validators. The selected draft changes the $schema declaration and can affect which keywords are understood by downstream software. Review the official JSON Schema specification when compatibility is critical.

How JSON type inference works

The JSON Schema Generator maps JSON strings, integers, numbers, booleans, null values, arrays and objects to corresponding schema types. It inspects array values to infer an item schema and walks nested objects recursively. When format detection is enabled, recognizable strings receive format annotations. A format is an annotation unless the chosen validation implementation enforces it, so do not treat formats as a complete security boundary.

Common JSON Schema generation errors

The source must be valid JSON with double-quoted property names and no trailing commas. A single sample cannot prove that a field is always required, that a string belongs to an enum, or that a number has a fixed range. Arrays containing unrelated value types may require a manual union. Empty arrays provide no evidence about their future item type, while null in one sample does not automatically reveal the non-null type expected at other times.

Best practices after generating a schema

Start with representative samples from several real requests or responses. Decide which fields are genuinely required instead of accepting every observed property blindly. Add descriptions, examples, bounds, patterns and enum values where they communicate business rules. Decide whether unknown properties should be accepted. Finally, test valid and invalid fixtures in the JSON Schema Validator, format the final file with the JSON Formatter, and compare revisions with the JSON Compare tool.