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 in this comprehensive n8n tutorial. Step-by-step guide with video, code examples, and expert tips from the n8n Zero to Hero course.

Table of Contents

Overview

This lesson is part of the n8n AI Automation - Zero to Hero course, Section: 3. Deep Dive Concepts.

Watch the video above for the full tutorial, or read the written guide below.

What is mock data and why does n8n need it for AI automation testing?

Mock data is fake, pre-defined input you inject into an n8n workflow so you can test every branch and edge case before connecting live APIs or production databases. It lets you avoid repeated external API calls (saving time and cost), simulate realistic scenarios like blank email fields, and work with predictable outputs during early development without risking accidental overwrites to live records.

How do you create mock data for n8n workflows?

Mockaroo (mockaroo.com) is the recommended first method. The free plan generates up to 1,000 rows of schema-matched data with typed fields ranging from email and credit card to airport code and datetime ranges. A blank-percentage control on each field lets you deliberately inject missing data, so your IF node branches get tested against incomplete inputs. An AI field generator lets you type a topic, such as "stock trades" or "flight logs," and it assigns matching column types and formulas automatically. You download the result as JSON, copy it, and paste it into any n8n node using the Edit Output icon to pin the data for the rest of the workflow.

ChatGPT or any LLM works as a second method when you need data shaped around a specific workflow. Prompt it with your workflow's purpose, required field count, and edge cases such as blank email IDs, and ask explicitly for a JSON list of items. If you ask for JSON and the first response comes back as individual objects rather than an array, n8n will reject the paste with an "unexpected non-whitespace character" error. Paste that error back into ChatGPT and ask it to reformat the output as a JSON list of items before retrying the pin.

The Edit Fields node and the Code node handle custom in-workflow generation as a third approach. Use the Edit Fields node in JSON mode for single-record tests during very early workflow development. Use the Code node when you need a for loop or calculated fields, returning every record wrapped in the {json: {...}} structure n8n expects. A fourth option, the built-in Customer Data Store node, returns at most five records regardless of the limit you set, making it useful only for practicing node mechanics, not for bulk or edge-case validation.

Key Takeaways

  • Mockaroo generates up to 1,000 typed, randomizable rows for free and exports JSON you paste directly into an n8n node via Edit Output to pin it as workflow input.
  • Blank-percentage controls in Mockaroo let you deliberately inject missing fields, such as empty emails, so your IF node gets tested against incomplete real-world inputs rather than a clean dataset.
  • ChatGPT mock data must be formatted as a JSON list of items, not individual objects. If n8n rejects the paste, copy the error back into ChatGPT and ask it to fix the array wrapping before retrying.
  • The Edit Fields node suits single-record early-stage tests; the Code node suits complex or programmatically generated datasets using a for loop with the {json: {...}} wrapper n8n requires.
  • The Customer Data Store node is capped at five records regardless of the limit you configure, making it suitable only for learning individual node concepts, not real workflow stress-testing.

Next Steps

Continue your n8n journey with the full n8n AI Automation - Zero to Hero course.

Frequently Asked Questions

Mockaroo's blank-percentage control sets any field to return empty values for a chosen share of rows. In n8n, this means your IF node or email-validation branch gets tested against realistic missing-data scenarios, like 20% of email fields being blank, without you hand-crafting those edge cases. It is one of the fastest ways to verify that your workflow handles bad input gracefully before production.

ChatGPT sometimes returns mock data as separate JSON objects rather than a single JSON array, and n8n's Edit Output pin requires a list of items. The error message reads "unexpected non-whitespace character after JSON." To fix it, paste that error message back into ChatGPT and ask it to reformat the output as a JSON list of items. The corrected array will pin without errors and expose all records to downstream nodes.

The Code node is the right choice when your test data requires custom logic that no external generator can produce, such as a for loop that builds calculated fields or values derived from other fields in the same record. Wrap every record in the `{json: {...}}` structure n8n expects and return the full array. For standard datasets, Mockaroo or ChatGPT are faster and require no code.

The Customer Data Store node returns a maximum of five records regardless of the row limit you configure. It is useful for learning how a specific n8n node behaves in isolation, but it cannot replicate bulk or edge-case scenarios. For any real workflow validation involving hundreds or thousands of rows, use Mockaroo, a ChatGPT-generated JSON list, or the Code node instead.

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