← All Posts

How to Generate Mock API Data for Testing

Published on February 7, 2026

Why Mock Data Matters

Mock data is essential for modern software development. When building a frontend application, you often need realistic data to test components, validate layouts, and demonstrate features — long before the backend API is ready. Mock data lets frontend and backend teams work in parallel, accelerating development cycles and reducing blocking dependencies.

Beyond frontend development, mock data is critical for unit testing, integration testing, documentation examples, database seeding, and demo environments. Using realistic fake data instead of placeholder values like "test" and "123" catches layout bugs, encoding issues, and edge cases that simplified data would miss.

Schema Definition

The foundation of mock data generation is the schema — a description of what the data should look like. A schema defines the structure of each record, including field names, data types, and any constraints. Think of it as a blueprint that the generator follows to produce realistic data.

// Example schema definition
{
  "fields": [
    { "name": "id", "type": "uuid" },
    { "name": "firstName", "type": "firstName" },
    { "name": "lastName", "type": "lastName" },
    { "name": "email", "type": "email" },
    { "name": "age", "type": "number", "min": 18, "max": 85 },
    { "name": "role", "type": "enum", "values": ["admin", "editor", "viewer"] },
    { "name": "createdAt", "type": "date" },
    { "name": "isActive", "type": "boolean" }
  ],
  "count": 10
}

A well-defined schema ensures that generated data is consistent, realistic, and ready to use directly in your application. The schema acts as a contract between the frontend and backend, documenting the expected data shape before the API is implemented.

Data Types

String Types

String generators produce realistic text values. Common string types include first names, last names, full names, company names, street addresses, cities, countries, and lorem ipsum paragraphs. Each type draws from a curated dataset to produce values that look real.

// String type examples
{ "type": "firstName" }   → "Alice", "Marcus", "Yuki"
{ "type": "lastName" }    → "Johnson", "Chen", "Patel"
{ "type": "company" }     → "Acme Corp", "Globex Industries"
{ "type": "address" }     → "742 Evergreen Terrace"
{ "type": "lorem" }       → "Lorem ipsum dolor sit amet..."
{ "type": "string" }      → Random alphanumeric string

Number Types

Number generators produce integers or floating-point values within a specified range. You can configure minimum and maximum bounds, decimal precision, and distribution patterns. This is useful for generating realistic prices, ages, quantities, and scores.

// Number type examples
{ "type": "number", "min": 1, "max": 100 }           → 42
{ "type": "number", "min": 9.99, "max": 999.99 }     → 149.95
{ "type": "number", "min": 0, "max": 1000000 }       → 587341

Specialized Types

Beyond basic strings and numbers, mock data generators support specialized types that produce correctly formatted values. These include email addresses, UUIDs, phone numbers, URLs, IP addresses, dates, and booleans. Using specialized types ensures that generated data passes validation rules and looks authentic.

// Specialized type examples
{ "type": "email" }     → "alice.johnson@example.com"
{ "type": "uuid" }      → "550e8400-e29b-41d4-a716-446655440000"
{ "type": "phone" }     → "+1 (555) 123-4567"
{ "type": "url" }       → "https://example.com/page/12345"
{ "type": "date" }      → "2026-01-15T09:30:00Z"
{ "type": "boolean" }   → true

API Response Wrapping

Real APIs rarely return a bare array of objects. They typically wrap the data in a response envelope that includes metadata like pagination info, total counts, status codes, and timestamps. A good mock data generator lets you wrap your generated records in a realistic API response structure.

// Typical API response envelope
{
  "status": "success",
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "firstName": "Alice",
      "lastName": "Johnson",
      "email": "alice.johnson@example.com",
      "age": 32,
      "role": "admin",
      "createdAt": "2026-01-15T09:30:00Z",
      "isActive": true
    }
    // ... more records
  ],
  "pagination": {
    "page": 1,
    "perPage": 10,
    "total": 247,
    "totalPages": 25
  }
}

Wrapping mock data in a response envelope means your frontend code can consume the mock data with the same logic it will use for the real API. This eliminates the refactoring step that would otherwise be needed when switching from mock data to live data.

Use Cases for Mock Data

Frontend developers use mock data to build and test UI components before the API exists. QA engineers use it to create test fixtures with specific data patterns. Technical writers use it to produce realistic documentation examples. DevOps teams use it to seed staging environments with representative data for load testing and demos.

Mock data is also valuable when the real data contains sensitive information. Instead of using anonymized production data (which is error-prone and may still leak PII), you can generate entirely synthetic data that has the same structure and statistical properties without any privacy concerns.

How to Use the Mock API Generator

Open the Mock API Generator and follow these steps:

  1. Define your schema — add fields with names and data types using the visual schema builder.
  2. Set the record count — choose how many records to generate (1 to hundreds).
  3. Generate the data — click generate to produce realistic mock JSON data based on your schema.
  4. Copy or download — use the generated JSON directly in your code, save it as a file, or integrate it into your testing pipeline.

The generator supports a wide range of data types including names, emails, UUIDs, numbers, dates, booleans, and custom enum values. It runs entirely in your browser and produces valid JSON output ready for immediate use.

Ready to generate mock data? Open Mock API Generator

Need to extract data from websites?

PulpMiner turns any webpage into a structured JSON API. No scraping code needed — just point, click, and get clean data.

Try PulpMiner Free

No credit card required