Batch Processing Completion Detection using 'noItemsLeft' - n8n Workflow

Learn how to use the 'noItemsLeft' context variable within an n8n workflow to accurately detect when the Split In Batches n8n node has finished processing all items.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers requiring precise control over asynchronous loops.

  • Users handling large datasets that need reliable confirmation of batch completion.

  • Anyone building custom n8n templates or seeking advanced flow control techniques in their n8n workflow.

Overview

This n8n workflow template demonstrates a powerful technique for managing flow control when processing data in batches. When dealing with potentially thousands of items, knowing exactly when the final batch has completed is crucial for initiating cleanup actions, notifications, or subsequent process steps. This n8n node demonstration leverages the specific context property noItemsLeft exposed by the Split In Batches n8n node. By checking this variable in a downstream IF n8n node, the n8n workflow ensures that the final completion action executes only once, after all items have been successfully processed.

How it Works

This n8n workflow template is designed specifically to showcase the internal mechanics of the Split In Batches n8n node.


  1. Start and Initialization: The n8n workflow begins with the Manual n8n trigger ('On clicking 'execute'').

  2. Data Generation: A Function n8n node generates 10 sample data items (simulating a large input dataset) to feed into the batch processor.

  3. Batch Splitting: The Split In Batches n8n node takes these 10 items and is configured to process them in batches of size 1.

  4. Completion Check: After each batch is processed, the flow proceeds to the IF n8n node. This crucial n8n node checks the expression {{$node["SplitInBatches"].context["noItemsLeft"]}}. The value of this context variable becomes true only during the final execution cycle, indicating that the source data stream has been fully consumed by the Split In Batches n8n node.

  5. Final Action: If the IF condition is true (meaning no items are left), the n8n workflow executes the final Set n8n node, which sets a confirmation message. If the condition is false, the processing loop continues implicitly until all batches are exhausted.

Installation Guide

To use this flow, follow these steps to import this valuable n8n template:


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

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

  3. Click 'New' and select 'Import from JSON'. Paste the copied n8n workflow JSON.

  4. Execution: Since this n8n template uses a manual n8n trigger, you can test the functionality directly by clicking 'Execute Workflow'. Observe the output paths of the IF n8n node in the execution log to see when the noItemsLeft condition evaluates to true.

Node Details

Manual Trigger (On clicking 'execute'): The starting n8n trigger for testing the n8n workflow structure easily.
Function: Generates 10 placeholder items (i=0 to i=9) to simulate a payload that needs batch processing. This custom code scripting allows for quick flow testing.
Split In Batches n8n Node: Core flow control n8n node. It splits the incoming 10 items into batches of size 1, cycling through the subsequent nodes until all items are processed. This n8n node makes the critical noItemsLeft context variable available.
IF n8n Node: The decision point. It checks for the batch completion status using the expression: ={{$node["SplitInBatches"].context["noItemsLeft"]}}. This is the key to accurately detecting the end of the batch operation within this n8n workflow.


  • Set n8n Node: Executes only upon batch completion (when noItemsLeft is true). It sets a simple message: "No Items Left," confirming the successful termination of the Split In Batches loop.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
ghagrawal17
ghagrawal17

Featured*