Loop Over Items only runs once — how to make it iterate through all items?

Hi everyone,

I’m trying to use the Loop Over Items node to go through each item coming from a Code node. The code splits some text into multiple rows (items), and I want to loop through each of them and write them one by one into a Google Sheet using the “Append row” node.

Later on, I plan to add more complex logic inside the loop, but for now, I just want to make sure it actually loops through all the items I provide.

Right now, it only runs once — it processes the first item, then stops. I tried adding a dummy node after the Google Sheets node to return the item back to the loop, but that didn’t help either.

How can I make Loop Over Items go through all the items I pass into it?

Thanks in advance for any help!

Hey @Ivan_Kostadinov hope all is well. Welcome to the community.

How did you run the workflow? Manually one node at a time or with a trigger?

I repro’ed your setup (the part with the loop and sheets):

When triggered, it goes over all items:

Hеу @jabbson

Thanks a lot for the response and for testing the flow!

Let me give you some more context so it’s clearer what I’m trying to achieve and what’s not working.

My workflow starts with a Gmail trigger. I receive an email that contains either a PDF or JPEG attachment. I extract text from the attachment, and at the end of the chain, I use a “Code” node to clean and split that text into multiple lines – one line per item (see screenshot).

The code returns an array like this:

json

[
  { "json": { "line": "Кух профил 60x40x0 – 60 бр." } },
  { "json": { "line": "Кух профил 30x40x0 – 10 бр." } },
  ...
]

Now I want to loop over each of these lines using the “Loop Over Items” node and append them one by one into a Google Sheet using the “Append row” node.

The Problem:

Even though the Code node clearly outputs 8 items, the Loop Over Items node only processes the first one, and then stops. It does not iterate through all 8 items.

I’ve tried:

  • Using “Run Once for All Items” in the Code node.
  • Making sure Loop Over Items receives the correct array.
  • Adding dummy nodes after Append row to force continuation.

Still, it only processes the first line.

Any idea what might be causing this or how to force Loop Over Items to iterate through all the incoming items properly?

Thanks again for the help!

Is there any possible you check the option in the loop node?

Unfortunately, that didn’t work either, but thanks a lot for the suggestion!

What if you don’t use the loop over items node to begin with? Most nodes in n8n can process multiple items one by one on their own without needing to explicitly looping over them. try to connect the output of the code node directly to the Google Sheets node.

1 Like

Thanks for the idea! I actually separated the logic and tested it by triggering the workflow with Gmail — and it works exactly as I want.

When triggered normally, everything loops correctly and writes to Google Sheets without issues. I just wanted to verify the loop behavior in isolation, but you’re right — in practice, I don’t even need the Loop Over Items node here.

Appreciate the help!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.