Sample Data Generation and Item Splitting using Code - n8n Workflow

Generate sample data records using the n8n Code node (JS/Python) and split them into individual items using the n8n Split Out node. Essential for testing complex n8n workflows and prototyping logic.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

n8n Developers and Automators: Those who need reliable, self-contained sample data for unit testing downstream processes.
Prototypers: Users quickly mapping data structures or testing list-based logic without relying on external APIs or databases.
Technical Content Creators: Individuals needing simple, reusable n8n templates demonstrating the power of the n8n Code node.
Flow Control Learners: Anyone looking to understand how the crucial n8n Split Out node manages item processing.

Overview

This fundamental n8n workflow provides a robust method for testing and prototyping automation paths without incurring costs or delays associated with external services. The primary goal is to generate 20 consistent, dummy records internally within n8n and then fan them out so that subsequent nodes process them one at a time.

This template demonstrates how the versatile n8n Code node can be utilized—offering implementations in both JavaScript and Python—to dynamically create complex data structures. The generated array is then perfectly prepared for the n8n Split Out node, which handles the essential task of transforming a single input item containing a list into multiple individual items. This is a crucial concept for anyone building advanced n8n automation, ensuring that every record in a batch receives separate attention from every downstream n8n node.

How it Works

This automation is initiated by a manual n8n trigger and immediately branches into two identical paths, demonstrating the same logic using different coding languages:


  1. Trigger Initiation: The process starts with the Start Workflow n8n trigger, designed for manual execution when prototyping or testing.

  2. Data Generation (Code Node): The flow enters two separate Code nodes (Generate Data Javascript and Generate Data Python). Both nodes execute a script that generates an array of 20 objects, each containing index, num, and test fields. This array is attached to the input item under the key barr. This technique ensures the code runs efficiently within the n8n node environment.

  3. Item Splitting (Split Out Node): The output from the code node (a single item containing an array of 20 records) passes to the Split Out n8n node. This specific n8n node is configured to look at the barr field. It executes the core flow control logic, splitting the array into 20 distinct output items. Each item now represents one of the generated records.

  4. Ready for Downstream: After the Split Out step, the n8n workflow is ready to map, transform, or send these individual data items to any target service (e.g., Google Sheets, a database, or another integration). This pattern is essential for reliable batch processing within any advanced n8n workflow.

Installation Guide

To start using this n8n workflow, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON code.

  2. Log into your n8n instance and navigate to the Workflows section.

  3. Click 'New' and then 'Import from JSON'. Paste the code and save the new n8n workflow.

  4. No Credentials Required: This specific n8n templates guide does not require external credentials as all logic is performed internally using standard n8n node types.

  5. Execution: Click 'Execute Workflow' or use the 'Start Workflow' n8n trigger node to run the process and observe the 20 items generated and split in the output of the Split Out nodes.

Node Details

The core functionality of this n8n workflow relies on the synergistic relationship between the Code node and the Split Out node.

Start Workflow (Manual n8n Trigger)
Function: Serves as the initiation point for the n8n workflow, allowing manual testing.
Key Configuration: Standard manual trigger setup.

Generate Data Javascript (n8n Code node)
Function: Uses JavaScript to programmatically create an array of 20 sample objects, useful for complex data creation in an n8n environment.
Key Configuration: The script generates 20 records and attaches the resulting array to item.json.barr.

Generate Data Python (n8n Code node)
Function: Achieves the identical result as the JavaScript version but using Python's list comprehension capabilities, demonstrating multi-language support within the n8n node structure.
Key Configuration: Language set to Python. Returns a list containing one item with the array attached to the barr key.

Split Out Javascript / Split Out Python (n8n Split Out node)
Function: The essential flow control n8n node that transforms a single input item containing an array into multiple output items (one for each element in the array). This is vital for processing data batches.
Key Configuration: Field To Split Out is set to barr, targeting the array generated by the preceding n8n node.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

Featured*