Skip to content
Salyro
Tool

JSON Schema sample generator

Build a sample JSON payload from a JSON Schema, then validate it with Salyro’s validator — shown as valid only when it passes, with reasons when not.

What it does

Paste a JSON Schema and get a JSON value that fits it: a payload for a test, a document or a request. The sample is then validated with the same validator and settings Salyro uses for an Output Contract, and the result says which of three things it is:

  • Valid: the validator accepted it. This is the only way a sample is shown as valid.
  • Not valid: the generator could not meet everything the schema asks. The validator's reasons are listed, so you can edit the sample.
  • Not checked: the schema does not compile as JSON Schema 2020-12, so nothing can say the sample is valid.

Everything runs in your browser: nothing you paste is sent anywhere. Send to validator opens the sample in the JSON Schema Validator.

How it builds a sample

From what the schema names, in this order: a const, the first enum value its type admits, then a value of the declared type.

  • Objects: every property, or only the required ones if you ask. Keys named in dependentRequired come along.
  • Lists: as many items as minItems asks, one when nothing does, never more than maxItems. Tuples follow prefixItems, and contains gets its items.
  • Limits: at most 100 items in a list, 10,000 characters in a string and 500,000 characters of text in the whole sample, property names included. A schema that asks for more gets a shorter sample, which the validator marks not valid, and the limit it hit is listed.
  • Strings: an example for common formats such as date-time, email and uuid, padded or cut to minLength and maxLength.
  • Numbers: inside minimum, maximum and their exclusive forms, and a multiple of multipleOf by the validator's own test.
  • References: $ref into the same schema is followed. A recursive schema stops after twelve levels.
  • Unions: the first anyOf or oneOf branch that is not only null. allOf parts are merged.

What it does not know

  • Patterns. It does not write a string to match a regular expression. A schema with a pattern usually gives a sample that is not valid, and says so.
  • not, if/then/else, propertyNames and similar. The keywords it does not read are listed. The validator still checks them, so a sample shown as valid satisfies them anyway.
  • Which oneOf branch to take. oneOf requires exactly one branch to match. When the first branch overlaps another, the sample is not valid, and the validator says so.
  • Realistic values. A sample is shaped right, not meaningful: "string", 0, false.

FAQ

Why is my sample marked not valid?

The validator refused it, and the reasons are listed with the rule each one breaks. The most common cause is a pattern.

Why does the generator not use examples or default?

A value the schema's author wrote is not guaranteed to fit the schema. Every sample is built by the generator and checked by the validator instead.

Sources

The rules are the JSON Schema 2020-12 specification. Validation uses the Ajv validator with the settings Salyro's engine uses.

Where the numbers come from

This tool works only on what you enter. It uses no external data and runs entirely in your browser.