IF Node Not Filtering Items Correctly Based on Condition

Hi guys, I’m having an issue with the IF node in n8n. I’m trying to filter items based on a condition, but it doesn’t seem to work as expected some items that should pass are getting filtered out, and vice versa.
My workflow is something like this
HTTP Request → IF → Continue processing
The data coming in looks like this:
[
{ “id”: 1, “status”: “active” },
{ “id”: 2, “status”: “inactive” },
{ “id”: 3, “status”: “active” }
]
But the output is inconsistent:
• Sometimes it only passes one item instead of all “active” ones
• Sometimes it sends items to the wrong branch
I also tried using an expression like this:{{$json.status === “active”}}
but I’m still seeing unexpected behavior.

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Keira_Becky

The issue is likely how the IF node evaluates items individually in n8n.

Each item is checked one by one, so your condition itself is fine, but the problem usually comes from data type or formatting differences.

For example, even if it looks like “active”, the actual value might be:
• "active " (extra space)
• “Active” (capital letter)
• or even null/undefined for some items

That would cause inconsistent results.

Your expression

{{$json.status === “active”}}

is correct, but to make it more reliable, you can normalize the value

{{$json.status && $json.status.toLowerCase().trim() === “active”}}

This handles:
• case differences
• extra spaces
• missing values

Also double-check in the execution preview that every item actually has a status field.

2 Likes

Thanks @Niffzy

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