JSON Schema Sample Generator

Generate an example document from a JSON Schema.

Open tool

Overview

Paste a JSON Schema and the sampler synthesises a single example document that conforms to every constraint - types, required fields, enums, ranges, formats. Use it to show an example payload in API docs, seed a test fixture, or sanity-check that a schema is actually satisfiable.

It's for developers maintaining OpenAPI specs, JSON Schema files, or any contract document where "here's what a valid instance looks like" is more useful than the schema itself. Reach for it when authoring docs, comparing two schemas, or producing a request body in Postman from a spec file alone.

How it works

The sampler walks the schema (Draft 2020-12 / Draft 7 compatible) and emits a value for each property using a default-per-type strategy: strings get short placeholders or pattern-conforming values, numbers get a midpoint of the allowed range, arrays default to one element unless minItems requires more, objects emit all required properties.

Constraints enum, const, format, pattern, minimum, maximum, minLength, maxLength are all respected. Internal $ref resolves; external refs aren't fetched.

Examples

  • Simple object schema:
    {
      "type": "object",
      "required": ["name"],
      "properties": {
        "name": {"type": "string"},
        "active": {"type": "boolean"}
      }
    }
    
    {"name": "string", "active": true}
    
  • Number range:
    {"type": "integer", "minimum": 1, "maximum": 100}
    -> 50
    
  • Email format:
    {"type": "string", "format": "email"}
    -> "user@example.com"
    
  • Enum:
    {"type": "string", "enum": ["red","green","blue"]}
    -> "red"  (first value)
    

FAQ

Does it always pick the same example value?

The single-sample mode is deterministic - same schema, same output. Use the bulk sampler for random variation across many records.

What if the schema is unsatisfiable?

If constraints contradict (e.g. minimum: 10, maximum: 5), the sampler reports an error rather than producing a non-conforming value.

Are $ref documents fetched over the network?

Internal $ref (within the same document) is resolved. External $ref (HTTP URLs) is not fetched - inline the relevant definitions to test them.

Does it produce valid OpenAPI examples?

Yes - OpenAPI schemas (the OpenAPI 3.x subset of JSON Schema Draft 2020-12) are supported. Paste the schema object from a components/schemas entry to see an example.

Try JSON Schema Sample Generator

An unhandled error has occurred. Reload ×