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
dependentRequiredcome along. - Lists: as many items as
minItemsasks, one when nothing does, never more thanmaxItems. Tuples followprefixItems, andcontainsgets 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,emailanduuid, padded or cut tominLengthandmaxLength. - Numbers: inside
minimum,maximumand their exclusive forms, and a multiple ofmultipleOfby the validator's own test. - References:
$refinto the same schema is followed. A recursive schema stops after twelve levels. - Unions: the first
anyOforoneOfbranch that is not onlynull.allOfparts are merged.
What it does not know
- Patterns. It does not write a string to match a regular expression. A schema with a
patternusually gives a sample that is not valid, and says so. not,if/then/else,propertyNamesand similar. The keywords it does not read are listed. The validator still checks them, so a sample shown as valid satisfies them anyway.- Which
oneOfbranch to take.oneOfrequires 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.
