How to Create Mock Data in n8n to test AI Automations without Live APIs

Learn how to create mock data in n8n to test AI automations without live APIs. Step-by-step guide using Mockaroo and custom data methods.

Table of Contents

Overview

In this tutorial, you will learn how to create mock data in n8n to test AI automation workflows without relying on live APIs or production data. We will explore multiple practical methods to generate realistic sample data, including using external mock data generators, leveraging AI-powered tools like ChatGPT, and creating custom mock data inside n8n itself. These techniques will help you build, debug, and optimize your workflows more efficiently while avoiding risks associated with live data.


Why Mock Data is Essential for AI Automation Workflows

Before diving into the methods, it’s important to understand why mocking data is a crucial practice when building AI automation workflows:

  • Test Without Live APIs: Avoid repeated calls to external APIs, saving time and reducing costs.
  • Simulate Real-World Scenarios: Real data may not always be readily available or diverse enough to cover edge cases.
  • Introduce Randomness: Randomized data better mimics real user behavior and uncovers potential issues.
  • Predictable Development: Small, controlled data sets produce predictable results, aiding debugging.
  • Protect Production Data: Prevent accidental overwrites or corruptions in your live environment during early development.

Mock data also helps you master error handling in n8n by allowing you to simulate failure scenarios safely. For more on this, check out our guide on Master Error Handling in n8n.


Method 1: Using an External Mock Data Generator (Mockaroo)

Mockaroo is a versatile online tool to generate large volumes of realistic mock data with customizable schemas.

Steps to Generate and Use Data from Mockaroo

  1. Create a Schema:

    • Define fields like ID, First Name, Last Name, Email, Gender, Company, etc.
    • Customize field types using Mockaroo’s extensive list (e.g., email, IP address, stock symbols).
    • Set options like the percentage of blank values for certain fields to simulate missing data.
  2. Add or Remove Fields:

    • You can add new fields or delete unnecessary ones.
    • Use formulas to create calculated fields (e.g., profit = sale price - purchase price).
  3. Use AI to Generate Fields:

    • Click on “Generate Fields Using AI” to automatically create fields for scenarios like flight logs or stock trades.
    • Specify time ranges and numeric ranges to control randomness.
  4. Generate Data:

    • Click “Generate Data” to produce your sample dataset.
    • Preview the data before downloading it.
  5. Download Data:

    • Export the data as JSON or CSV files.
  6. Import Data into n8n:

    • Open your n8n workflow.
    • Add a Manual Trigger node.
    • Click the node’s output “Edit” icon to open the editable mode.
    • Paste the JSON mock data directly into the node’s output.
    • Save and pin the data for further use in your workflow.

Example: Filtering Stock Trades Using an IF Node

After loading mock stock transaction data:

  • Add an IF node.
  • Set the condition to check if the transactionType equals buy.
  • Execute the node to split records into buy and sell branches.
  • Build your automation logic based on these branches.

This approach integrates well with other nodes such as the Gmail node for sending notifications. For details on configuring email workflows, refer to the n8n Gmail node documentation.


Method 2: Generating Mock Data Using AI (ChatGPT)

You can leverage AI language models like ChatGPT to generate custom mock data tailored for your workflow needs.

How to Use ChatGPT for Mock Data Generation

  1. Prepare a Prompt:

Example prompt:

I'm working on an n8n automation workflow simulating user signups for email automation. 
Please generate about 1000 random mock user signup records with at least six fields, 
including email ID. Include some blank email IDs to simulate missing data. 
Provide the data both in CSV and JSON formats.
  1. Request Data in CSV Format:

    • Ask ChatGPT to provide data in CSV format for easy import into tools like Google Sheets.
  2. Request Data in JSON Format:

    • Ask ChatGPT to provide the same data as a JSON list, suitable for direct use in n8n nodes.
  3. Download and Review the Data:

    • Save the generated CSV and JSON files.
    • Open and verify the data structure and content.
  4. Import JSON Data into n8n:

    • Open the Webhook or Manual Trigger node in your workflow.
    • Use the “Edit Output” feature to replace the default output with the JSON mock data.
    • Save and pin the data to simulate incoming requests.

Troubleshooting JSON Format Errors

  • Error: Unexpected non-whitespace character after JSON at position ...
  • Cause: JSON data is not properly formatted as a list of objects.
  • Fix: Ask ChatGPT to return the data wrapped in a JSON array (list of items).

Example correction prompt:

Please format the JSON data as a list of items (JSON array).

Once fixed, the mock data can be used seamlessly in your workflow to simulate user signups or other events.


Method 3: Creating Custom Mock Data Inside n8n

For quick tests or simple data structures, you can create mock data directly within n8n using the Set (formerly Edit Field Set) or Code nodes.

Using the Set Node for Single Records

  • Add a Set node to your workflow.
  • Manually add fields and values (e.g., order number, customer name, email).
  • You can nest JSON objects to represent complex data (e.g., an order with multiple products).
  • This method is ideal for small-scale or early-stage testing with a few records.

Using the Code Node for Programmatic Data Generation

  • Add a Code node.
  • Use JavaScript to generate arrays of mock data dynamically.
  • Return data in the format n8n expects:
return [
  {
    json: {
      orderNumber: '12345',
      customerName: 'John Doe',
      email: 'john.doe@example.com',
      products: [
        { name: 'Product A', quantity: 2 },
        { name: 'Product B', quantity: 1 }
      ]
    }
  },
  // Add more records as needed
];
  • You can write loops and logic to create large datasets with custom rules.

For more on handling complex data and binary files within n8n, see our lesson on File Management & Binary Data in n8n.


Method 4: Using the Customer Data Store Node (Limited Use)

n8n offers a Customer Data Store node that contains a small set of sample data.

  • Add the Customer Data Store node.
  • Use the Get All People action to retrieve sample records.
  • Note: The node has a limited dataset (e.g., 5 records), so it’s not suited for large-scale testing.
  • Useful for quick demos or learning purposes.

Putting It All Together: Example Workflow Using Mock Data

  1. Start with a Manual Trigger or Webhook node.
  2. Load mock data into the node output using the "Edit Output" feature.
  3. Use an IF node to filter or branch your data based on field values.
  4. Add additional nodes for processing, e.g., Google Sheets, Slack, Notion, Airtable.
  5. Test the workflow with your mock data to ensure all branches and nodes behave as expected.

For example, you might integrate a Google Forms Webhook in n8n to simulate form submissions as part of your testing workflow.


Common Mistakes and Troubleshooting Tips

  • Improper JSON Formatting:

    • Always ensure your JSON mock data is a properly formatted array of objects.
    • Use JSON validators or ask AI tools to reformat if errors occur.
  • Data Field Mismatch:

    • Make sure the mock data fields match exactly with what your workflow nodes expect.
    • Missing or extra fields can cause errors or unexpected behavior.
  • Large Data Volume Overload:

    • Avoid loading too many records at once in early testing to keep execution fast.
    • Gradually increase dataset size once your workflow logic is stable.
  • Not Pinning Edited Data:

    • After pasting mock data into a node’s output, always pin it to freeze the data for consistent testing.
  • Ignoring Missing Data Scenarios:

    • Include blank or null values in fields like email to test how your workflow handles incomplete data.


Quick Reference Cheat Sheet

Method Use Case Pros Cons
Mockaroo Large realistic datasets Easy UI, customizable, AI fields Requires export/import step
ChatGPT Custom, large datasets in CSV/JSON AI-generated, flexible prompts May need JSON formatting fixes
Set Node Simple single-record testing Quick, no external tools Not suited for bulk data
Code Node Custom logic and large dataset generation Fully programmable, flexible Requires JavaScript knowledge
Customer Data Store Node Small predefined sample data Built-in, no setup needed Very limited dataset

By mastering these methods, you can confidently create and manage mock data in n8n, enabling faster, safer, and more effective AI automation workflow development. As shown in the video above, combining external tools with n8n’s native features offers powerful options to simulate real-world data scenarios without the risk or overhead of live environments.

Frequently Asked Questions

Generate mock data in Mockaroo, export it as JSON, then paste it into a Manual Trigger node's output in n8n to use it in your workflow.

Yes, you can manually create and pin JSON mock data using the Manual Trigger node or use function nodes to generate dynamic sample data within n8n.

Mock data prevents repeated live API calls, protects production data, simulates real-world scenarios, introduces randomness, and helps debug workflows predictably.

Use Mockaroo’s options to set percentages of blank fields or formulas for calculated fields, or generate randomized data using AI-powered tools integrated into your mock data process.

Yes, after importing mock data, you can use nodes like IF to filter records based on conditions, such as transaction types, to test workflow logic effectively.

Dheeraj Sharma

Dheeraj Sharma

AI Systems Builder
Creator of the n8n Zero to Hero course (42 lessons, 31+ hours). I help solopreneurs build AI systems that grow revenue without growing workload.

Get the n8n Mastery Bundle

All workflows, cheat sheets, and premium resources from the entire course in one package.

Get Premium Resources