Mock JSON Generator
Generate realistic mock JSON data from a JSON Schema definition. Specify properties, types, constraints, and formats — the engine produces sample records that satisfy the schema rules, perfect for API testing and prototyping.
Mock JSON Generator
Generate realistic mock JSON data from a JSON Schema definition. Perfect for API testing and prototyping.
How to Use the Mock JSON Generator
Write a JSON Schema describing your desired data structure, set the number of records to generate, and click Generate Mock Data. The generator produces compliant data that satisfies every constraint defined in the schema. Use the Simple and Nested sample buttons to load pre-built schemas and see the tool in action instantly. All generation occurs client-side with no data sent to any server.
A frontend developer building a React or Vue component that consumes a REST API generates dozens of realistic mock records to test rendering, pagination, and edge cases before the backend is ready. The generated data respects type constraints, so email fields contain valid emails and numeric fields stay within the defined range.
A full-stack engineer setting up a local development database defines a schema for users, products, or orders and generates a batch of seed data. This eliminates the need to manually craft test records or install heavyweight mocking libraries.
A UI/UX designer creating wireframes or high-fidelity prototypes needs realistic content to evaluate layout, spacing, and responsive behaviour. The generator produces data that looks like real records, making it possible to identify overflow, truncation, or alignment issues that placeholder text would not reveal.
A performance engineer generates large batches of mock records to create realistic request payloads for load testing an API endpoint. The schema constraints ensure the test data matches the production data shape, giving accurate performance measurements.
How the Mock JSON Generator Works
The generator reads your JSON Schema and recursively produces a random value for each property based on its declared type and constraints. The schema is parsed with JSON.parse(), and the generator traverses the schema tree, selecting a generation strategy for each property.
Type Detection and Constraint Resolution
For each property, the generator reads the type field and selects a generation strategy. Strings are generated using a pool of lowercase characters, with length controlled by minLength and maxLength. Integers and numbers use minimum/maximum and exclusiveMinimum/exclusiveMaximum to define the range. Booleans are random true/false values. Arrays use minItems/maxItems to control length, and each element is generated from the items schema.
Format Pattern Generation
When a format keyword is present, the generator produces values that match the specified pattern. Email generates realistic email addresses from name pools and domain lists. Date-time produces ISO 8601 timestamps. UUID calls crypto.randomUUID() for v4 UUIDs. IPv4 and IPv6 generate valid IP address formats. The enum keyword randomly selects from a fixed list of allowed values, and const returns the specified constant.
Nested Schema Resolution
Object and array types are resolved recursively. A property with type object generates its own sub-properties based on the nested properties definition. Arrays generate a random number of elements between minItems and maxItems, each conforming to the items schema. This recursive approach supports arbitrarily deep nesting, allowing complex data models with multiple levels of embedded objects and arrays.
Frequently Asked Questions
What JSON Schema features are supported?
The generator supports type, properties, items (for arrays), enum, const, minimum/maximum, exclusiveMinimum/exclusiveMaximum, minLength/maxLength, pattern, format, and required fields. Draft-07 compatible schemas are fully supported. Keywords like $ref, allOf, and oneOf are not currently resolved.
What format patterns produce realistic data?
Supported formats include email for realistic email addresses, date-time for ISO 8601 timestamps, date for YYYY-MM-DD strings, time for HH:mm:ss, uri for HTTPS URLs, uuid for v4 UUIDs via crypto.randomUUID(), hostname for domain names, and ipv4/ipv6 for IP addresses. Each format produces contextually appropriate values rather than random strings.
Does it handle nested object and array schemas?
Yes. The generator recursively resolves nested object and array schemas. A property with type object generates its own sub-properties from the nested properties definition. Arrays produce a random number of elements between minItems and maxItems, each conforming to the items schema. This supports arbitrarily deep nesting for complex data models.
Is the generated output always valid JSON?
Yes. The output is always valid, parseable JSON. Each generated record is produced by the generateValue function which returns a value matching the declared type and constraints. The final output is serialised with JSON.stringify using 2-space indentation for readability.
What happens if the schema is invalid or incomplete?
If the schema is not valid JSON, the tool displays the exact error message from the JavaScript engine in a red error box below the input area. If the schema is valid JSON but does not conform to JSON Schema conventions, such as missing a type field, the generator returns null for unrecognised properties. Ensure your schema includes at minimum a type field at the root level.