Mock data generation
Generate realistic mock data from TypeScript models
Mock API Studio generates local mock records from TypeScript response models. It combines field types, meaningful property names, explicit Faker mappings, endpoint record counts, and an optional deterministic seed, then stores the resulting collection in the project’s local SQLite database.
Infer useful values from the model
Primitive and nested TypeScript shapes define the JSON structure. Semantic field names such as email, firstName, price, city, url, createdAt, and phone guide the generator toward realistic values. String literal unions and string-valued enums constrain generated values to their declared choices.
interface Product {
id: string;
name: string;
price: number;
category: "keyboards" | "mice" | "displays";
inStock: boolean;
}
type MockApiStudioResponse = Product[];Use explicit Faker mappings when inference is not enough
Endpoint field settings can select supported Faker functions for product names, prices, people, addresses, URLs, dates, UUIDs, sentences, and other common data. Explicit mappings are useful when a property name does not communicate the value you need.
Generation does not understand arbitrary business rules. Use clear field names, declared enum choices, and the available field settings for the most predictable result.
Reproduce data with a seed
A project seed initializes Faker before records are generated. Resetting with the same seed, schema, record count, and generator settings produces the same initial sequence. Changes to any of those inputs can change the generated records.
Seed: 8142
First reset → product names A, B, C
Second reset → product names A, B, C
# Keep the model and generation settings unchanged.Generate relationships without orphans
The runtime generates parent resources before assigning child foreign keys. It chooses those keys from real parent records, which keeps the initial relational dataset valid. Parent deletion is blocked with HTTP 409 while child records still reference it.
- Collection record counts are configurable per endpoint.
- Optional fields may be omitted from some generated records.
- POST and PATCH can change the local dataset after generation.
- POST /_mock/reset replaces local changes with freshly generated records.
Supported model boundaries
The generator handles serializable model shapes. Functions, conditional and mapped types, indexed-access expressions, type operators, and non-string enums are rejected by model workspace validation. Export a concrete JSON-like interface or alias when an application type is too abstract to generate directly.
Related questions
How do I generate mock data from a TypeScript interface?
Bind the interface to an endpoint with MockApiStudioResponse, configure its record count and optional field mappings, then start or reset the local runtime.
Can Faker data be deterministic?
Yes. Use a project seed and keep the schema and generation settings unchanged to reproduce the same initial sequence.
How are parent-child relationships kept valid?
Child foreign keys are assigned from keys that exist in the generated parent collection.
Keep exploring
Last updated September 17, 2026. Product behavior described here is verified against the current Mock API Studio runtime.