N8N

n8n loop over items node

When building workflows in n8n, you’ll often fetch multiple items.

For example: Fetching a list of users, Rss feed urls or database rows.

What if you need to process these items one at a time instead of all at once.

That’s where the node loop over items comes in, It let’s you go through a list if things and run a separate process for each one.

Before we start, if you are looking for help with a n8n project, we are taking on customers. Head over to our n8n Automation Engineer page.

What Is the Loop Over Items Node?

The Loop Over Items node is designed to process an array of items individually. Instead of sending all items downstream at once, it passes them one by one, or in small batches if configured.

 

You’ll typically use it when:

  • A downstream node can only process one item at a time (e.g., RSS Feed Read).

  • You need to perform personalized actions for each item (e.g., send custom emails).

  • You want to control the execution order.

How It Works

  • Input: It receives an array of items (e.g., multiple URLs).

  • Loop: It picks the first item and passes it to the next node.

  • Execution: The connected nodes process the item.

  • Repeat: It goes back, picks the next item, and repeats until all items are processed.

  • Output: By default, it outputs the last processed item, but you can merge results afterward.

Node Configuration

The Loop Over Items node has several useful settings:

  • Batch Size → Number of items processed per loop cycle. (Set to 1 for strict one-by-one execution.)

  • Result Handling → Decide whether to output each item individually or collect results.

  • Context Variables (accessible with expressions):

    • {{$node["Loop Over Items"].context["noItemsLeft"]}} → Returns false if there are more items, true if finished.

    • {{$node["Loop Over Items"].context["currentRunIndex"]}} → Returns the current loop index (starting at 0).

Example 1 : Loop Over a List of Users

Let’s create a workflow that loops over a list of users and generates a personalized message for each user.

Create a Set Node (Edit Fields Node)

Add a Set node and configure it like this:

  • Set the output with the following Json
				
					
[
{
"name": 
"Sean",
"email": 
"sean@example.com"
},
{
"name": 
"Kane",
"email": 
"kane@example.com"
},
{
"name": 
"Charlie",
"email": 
"charlie@example.com"
}
]
				
			

This creates an array of users.

Add the Loop Over Items Node

  • Connect the Code node → Loop Over Items node.

  • Configure it as follows:

    • Batch Size1 (to process users one by one).

Add a Code Node (Process Each User)

  • Connect the Loop Over Items node → Function node.

  • In the Code node, add this code:

  • Set the mode to run on each item
				
					const user = $json;

return [
	{
		json: {
			message: `Hello ${user.name}, your email is ${user.email}`
		}
	}
];

				
			

This generates a personlized message for each user.

Execute the Workflow

When you run the workflow:

  1. The Code Node outputs three users.

  2. The Loop Over Items Node processes them one at a time.

  3. The Function Node returns:

    • "Hello Sean, your email is sean@example.com"

    • "Hello Kane, your email is kane@example.com"

    • "Hello Charlie, your email is charlie@example.com"

Final thought

The Loop Over Items node is essential for workflows that need item-by-item processing. Whether you’re iterating over users to send personalized messages or fetching multiple RSS feeds, this node gives you full control over sequential execution.

By combining it with processing nodes, you can build powerful workflows that stay modular, maintainable, and easy to debug.

 

 

Thank you for reading this article. Make sure to check out our other n8n content on the website. If you need any help with n8n workflows we are taking on customers so reach out

Leave a Reply

Your email address will not be published. Required fields are marked *