Guide

How to Generate a JSON Schema from Sample Data

Paste a valid JSON sample, optionally add a title, and submit it to generate an inferred JSON Schema representation. Review the result because it reflects the supplied sample, not constraints that the sample does not show.

Tool JSON Schema Generator

What the JSON Schema Generator does

Schema Generator turns a JSON sample into a JSON Schema representation. It is useful when you have example payloads and want a starting point for documenting their structure or preparing a schema for later review. You can also provide an optional title for the generated schema.

The result reflects the values and structure observed in the sample. It should therefore be treated as an inferred starting point rather than a statement of every rule your data may need. For example, a sample can show that a field is present and numeric without expressing business rules that were not represented in the input.

How to generate a schema from a JSON sample

  1. Prepare a valid JSON sample. Use an object when you want named properties, an array when you want to describe a list, or a primitive value when the sample itself is a string, number, Boolean, or null.

  2. Enter the sample in the primary sample-data field. The input is treated as text and parsed as JSON. If that field is blank, the tool can use a suitable value from one of its alternative input fields, including json, data, text, input, value, or sample.

  3. Add a title if you want a label other than the default. Leaving the title empty produces the default title “Generated Schema.”

  4. Submit the input to generate the schema. Keep the selected input below 1,000,000 bytes when encoded as UTF-8. The tool rejects malformed JSON, so check commas, quotation marks, braces, brackets, and value types before submitting.

  5. Review the generated representation. For an object, inspect the property schemas, required member names, and the handling of properties not present in the sample. For an array, inspect the item schema. For strings, check whether a recognized format such as email, UUID, URI, IPv4, date-time, date, or time was inferred.

  6. If the operation fails, first confirm that a usable sample was supplied and that it is valid JSON. Then check the input size. A blank primary field can still fail when no suitable alternative value is available.

How to read and review the result

The generated result describes the parsed sample rather than an intention that was not expressed in it. An object becomes an object schema with a property schema for each member observed. Observed member names are listed as required, and properties outside that inferred set are disallowed. This can be helpful for documenting a fixed sample shape, but it may be stricter than the data model you intend if your real payloads omit fields or add fields in other cases.

An array becomes an array schema. An empty array leaves its item schema unconstrained, while differing item shapes can be represented as alternatives. Primitive values map to their corresponding types: null, Boolean, integer, or number. A string remains a string and may receive a recognized format when its value matches one of the tool’s supported patterns.

The result includes the JSON Schema draft-07 identifier. Review the schema before adopting it, especially when the sample contains only one example. The tool does not repair malformed JSON or guarantee that the inferred representation captures constraints that were not visible in the sample.

Worked example

A developer has one customer payload and wants a draft schema that records its observed email and age fields.

Enter {"email":"alex@example.com","age":42} as the JSON sample, set the title to Customer, and submit it.

The result has an object schema with property schemas for email and age, lists both observed members as required, disallows additional properties, and includes the JSON Schema draft-07 identifier. The email string may also receive the email format.

Limitations

  • The result is inferred from the supplied sample. It may not express business rules, optionality patterns, additional valid properties, or other constraints that do not appear in that sample.

Common errors

  • A frequent cause of failure is submitting malformed JSON or leaving both the primary sample field and alternative inputs without usable data. Correct the JSON syntax and provide a nonblank sample before submitting again.

FAQ

What title does the generator use if I leave the title blank?

Yes, when the title field is empty, the tool uses “Generated Schema.” A supplied title is used instead.

Can the tool fix invalid JSON for me?

It rejects malformed JSON rather than converting it into a schema. Check the syntax and submit a valid JSON value.

How does the generator handle JSON arrays?

An empty array produces an array schema with an unconstrained item schema. Arrays with differing item shapes can be represented as alternatives.

Tool

JSON Schema Generator