Skip to content
gohacks.dev
APIs

Sample JSON From JSON Schema

Generate a sample JSON document from a JSON Schema, using its examples, defaults, enums and formats, with an option for required properties only.

Free · No sign-up · Your inputs stay in your browser

Input

Generate sample JSON from a JSON Schema

Output

Sample

211 characters

Uses the schema's own examples, default, const and first enum value where it has them, otherwise a value that satisfies the type, format, minimum and length constraints. Local $ref, allOf and the first branch of oneOf and anyOf are followed. Good for mocking an API response or seeding a contract test; the required-only version shows the smallest valid payload.

Runs in this browser. Nothing you paste is sent to a server.

Uses

Mock API responses for frontend work before the backend exists, seed a contract test with a valid request body, show an example in documentation that is guaranteed to match the schema, or see the smallest valid payload with required-only mode. OpenAPI component schemas work too, because OpenAPI 3.1 schemas are JSON Schema.

Plausible, not realistic

Values are chosen to pass validation, not to look like production data. Add examples to the schema itself (the examples keyword) and they are used here, in documentation and by mock servers such as Prism.

Share

Frequently asked questions

Does the sample always validate against the schema?
For the common keywords, yes. Patterns, uniqueItems and complex if/then/else constraints are not solved, so check unusual schemas with the JSON Schema validator.
How do I get a minimal valid payload?
Turn on Required properties only. Optional properties are left out at every level.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools