Skip to content
Simple Tools

Practical guide

How to generate sample JSON from a schema

A sample helps prepare integration tests or documentation but cannot replace a test suite. This guide covers deterministic generation of one document, choosing members and checking the supported schema rules.

Simple Tools editorial teamReviewed: 2 October 2026

Choose the schema and member scope

Paste the JSON schema, choose all declared members or required members and select “Process”. Output is one compact JSON document, not a batch of random records. Running the same schema and options again gives the same sample. Use the formatter separately for readable indentation without changing values and types.

Required scope can also include members needed for minProperties. All scope skips optional members forbidden by false and can trim optional members to satisfy maxProperties. Therefore, do not assume every properties key appears. The generator does not invent undeclared names merely to reach a minimum member count.

Compare both scopes with an example

The table uses schema {"type":"object","properties":{"city":{"type":"string","default":"Łódź"},"count":{"type":"integer","minimum":1}},"required":["city"]}. city is required and count is optional. The city default satisfies its type rule, so it can appear in the sample. The generated one satisfies minimum but represents no real count of residents, products or events.

Before presenting a sample as an API example, check whether the receiver allows count to be omitted and permits extra members. Listing a key in properties does not make it required. Prepare separate cases for missing members, null and empty strings: one sample cannot describe all states, and null is not the same as an absent key.

One schema, two scopes
ScopeJSON sample
all{"city":"Łódź","count":1}
required{"city":"Łódź"}

Use hints without expecting realism

The generator checks candidates from const, default and enum, plus anyOf branches. A default hint must satisfy the other rules or it is not accepted. Basic types use placeholders: example or repeated x for strings, zero or candidates near bounds for numbers, and arrays based on minItems or one item where allowed.

This is not a generator of Polish names, addresses, dates or identifiers. It creates no statistical distribution and does not cover every anyOf branch. A schema with default can already contain real data; local processing does not anonymize those values. Review hints before pasting and label saved output as a synthetic sample for isolated tests.

Separate no candidate from conflicting rules

Generation uses the validator’s bounded 2020-12 profile. Unknown keywords, including $ref, format, pattern, oneOf and uniqueItems, are rejected. The final document is parsed and checked against rules again before display. No output does not prove the schema contradictory: candidate search is bounded and cannot solve arbitrary combinations of constraints.

With exclusiveMinimum: 0.1 and exclusiveMaximum: 0.2, simple attempts may find no number. A valid default: 0.15 supplies a candidate without weakening rules. A false schema really rejects every value. Do not remove constraints to force output; for complex cases, prepare your own sample and validate it with a tool suited to the full contract.

Check limits and expand the test suite

Schemas allow up to 50,000 UTF-16 units, 256 nodes and 16 subschema levels. Samples allow 1,000 values, 100 items per array and 1,000 Unicode code points per string. Limits apply to const, default and enum values as well as automatic placeholders. A large annotation cannot bypass the safeguards.

Add separate tests for missing required members, wrong types, numeric boundaries, empty containers and extra keys. Check output in the destination, especially large-number handling and Polish character encoding. One valid sample cannot establish every integration works or that the schema correctly describes business needs. Keep original requirements alongside the example document.

Privacy and handing off output

Use short synthetic examples without customer data, passwords or API keys. Input and output stay in browser memory: the tool does not send them to analytics, put them in the page URL or keep history in localStorage or sessionStorage. Opening the page still connects your device to hosting. Browser extensions and other software on your device can have their own access to content.

Copying requires a separate click. Editing a field clears old output; process again after each change. “Clear” resets the form and options but cannot remove earlier clipboard copies, downloaded files or printouts. To report a problem, give the chosen mode, a small anonymized example and expected output. Before handing output off, check encoding and how the receiving application reads it.

Frequently asked questions

Are results random?

No. The same schema and scope give one deterministic sample, not a random record batch.

Will default always appear in output?

No. It is a candidate and must satisfy the remaining rules.

Does no output mean an invalid schema?

Not always. Bounded search can miss a valid sample. Check the message, supported profile and a candidate of your own.

Does reset remove copied data?

No. Reset clears the form and output, but earlier clipboard copies, files and printouts need separate removal.

Sources and scope

Examples are synthetic. Profiles and limits describe this site, not entire standards. Output does not establish API, XSD or business-rule compliance. Check it in the destination system before use.

Tools covered by this guide

Generator

JSON Schema validator

Check JSON data against a declared 2020-12 schema profile without network references or data mutation.

Generator

Sample JSON generator

Create one deterministic sample from a bounded schema and check it before returning output.

Generator

JSON to XML converter

Write JSON in a declared typed profile or reconstruct elements from an XML tree without guessing types.

Generator

XML to JSON converter

Read the typed profile or ordinary XML as a tree retaining attributes, text and child order.