DEV Community

Pirate Prentice
Pirate Prentice

Posted on

n8n Filter Node: How to Remove Unwanted Items from Your Workflow Data (Free Examples)

If your workflow processes a list of items — webhook payloads, spreadsheet rows, API results — you almost always need to filter some of them out before taking action.

The n8n Filter node is how you do that. It checks each item against one or more conditions and only passes the items that match. Items that don't match are silently dropped.

In this guide I'll cover:

  • How the Filter node works
  • Single and multiple conditions (AND / OR)
  • Common field types and operators
  • A real-world example: filtering Stripe webhook events
  • Free workflow JSON you can import today

What the Filter Node Does

The Filter node evaluates each item in the incoming data independently. For every item:

  • If the condition(s) pass → the item flows to the next node
  • If the condition(s) fail → the item is dropped (not routed anywhere)

This is different from the IF node, which routes items to two branches (true / false). The Filter node has only one output — the items that pass.

Use the Filter node when you want to narrow down a list and don't need to do anything special with the rejected items.


Basic Setup

  1. Add a Filter node after any node that outputs multiple items
  2. Set the field to evaluate (e.g. {{ $json.status }})
  3. Choose an operator (equals, contains, greater than, etc.)
  4. Set the value to compare against
  5. Done — only matching items continue

Single Condition Example

Scenario: Your webhook receives all Stripe events. You only want to process payment_intent.succeeded events.

Field Operator Value
{{ $json.type }} equals payment_intent.succeeded

All other event types are filtered out before they hit your email or CRM node.


Multiple Conditions: AND vs OR

The Filter node supports combining multiple conditions:

AND (all must be true)

Every condition must pass for the item to continue.

Example: Only process US customers with orders over $100:

  • {{ $json.country }} equals US
  • {{ $json.order_total }} greater than 100

OR (any one must be true)

If any condition passes, the item continues.

Example: Flag items that are either overdue OR high-value:

  • {{ $json.days_overdue }} greater than 30
  • {{ $json.amount }} greater than 10000

You can mix AND and OR groups using the Add condition group button — conditions within a group are ANDed; groups themselves are ORed.


Operators by Data Type

String fields

Operator What it checks
equals exact match (case-sensitive)
not equals doesn't match
contains substring present
not contains substring absent
starts with prefix match
ends with suffix match
regex custom pattern
is empty field is "" or null
is not empty field has a value

Number fields

Operator What it checks
equals / not equals exact value
greater than strictly above
less than strictly below
greater than or equal above or matching
less than or equal below or matching

Boolean fields

Operator What it checks
is true value is truthy
is false value is falsy

Array fields

Operator What it checks
contains array includes this value
not contains array doesn't include this value
length equals array has exactly N items
is empty array has 0 items

Common Gotcha: Type Mismatch

If you compare {{ $json.amount }} (a number) to "100" (a string), the condition may silently fail. Always make sure the value type on the right side matches the field type on the left.

To force a type, use an expression:

  • {{ Number($json.amount) }} — coerce to number
  • {{ String($json.status) }} — coerce to string

Real-World Example: Filtering Support Tickets by Priority

Goal: A Typeform webhook sends all support tickets. You only want to alert your Slack channel for priority = high tickets.

Flow:

Webhook → Filter (priority equals "high") → Slack
Enter fullscreen mode Exit fullscreen mode

Filter condition:

  • Field: {{ $json.answers.priority }}
  • Operator: equals
  • Value: high

Low and medium tickets are dropped before hitting Slack. You can add a second branch later with an IF node if you want to log non-urgent tickets to a Sheet.


Free Workflow JSON

Here's an importable n8n workflow that demonstrates the Filter node with a mock dataset. It generates 5 items, filters to only those with status = active and score > 50, then outputs the results.

Import this in n8n: Menu → Import from URL / JSON → paste below

{
  "name": "Filter Node Demo",
  "nodes": [
    {
      "parameters": { "jsCode": "return [\n  { json: { id: 1, name: 'Alice', status: 'active', score: 72 } },\n  { json: { id: 2, name: 'Bob', status: 'inactive', score: 88 } },\n  { json: { id: 3, name: 'Carol', status: 'active', score: 45 } },\n  { json: { id: 4, name: 'Dave', status: 'active', score: 91 } },\n  { json: { id: 5, name: 'Eve', status: 'inactive', score: 30 } }\n];" },
      "id": "code-node-1", "name": "Mock Data", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [250, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            { "id": "cond-1", "leftValue": "={{ $json.status }}", "rightValue": "active", "operator": { "type": "string", "operation": "equals" } },
            { "id": "cond-2", "leftValue": "={{ $json.score }}", "rightValue": 50, "operator": { "type": "number", "operation": "gt" } }
          ],
          "combinator": "and"
        }
      },
      "id": "filter-node-1", "name": "Filter: active + score > 50", "type": "n8n-nodes-base.filter", "typeVersion": 1, "position": [500, 300]
    }
  ],
  "connections": { "Mock Data": { "main": [[{ "node": "Filter: active + score > 50", "type": "main", "index": 0 }]] } }
}
Enter fullscreen mode Exit fullscreen mode

Expected output: Alice (72) and Dave (91) — the two active users with scores above 50.


Filter vs IF Node: When to Use Each

Scenario Use
Drop unwanted items, nothing special for rejects Filter
Route items two ways (true path + false path) IF
Three or more routing paths Switch
Remove duplicate items Remove Duplicates

Combining Filter with Other Nodes

Filter → Set: Keep only relevant items, then reshape their fields before saving to a database.

Filter → Split in Batches: Narrow a large list down before processing in chunks to stay within API rate limits.

Filter → HTTP Request: Only call an external API for items that meet your threshold (saves API quota and cost).


Quick Tips

  1. Test with sample data first — run your upstream node, pin the output, then build Filter conditions against real data.
  2. Use expressions for dynamic values{{ $json.threshold }} instead of hardcoding numbers means you can drive filters from config fields.
  3. Chain filters — two simple Filter nodes is often cleaner than one Filter with six AND conditions.
  4. Log what you filtered out — if you need to audit dropped items, route them through an IF node instead and write the false branch to a Sheet.

What's in the n8n Workflow Starter Pack?

The free JSON above shows the Filter node pattern. The n8n Workflow Starter Pack ($29) includes 10 production-ready workflow templates covering the full automation stack:

  • Lead capture → CRM → welcome email
  • Stripe payment → receipt → fulfillment trigger
  • Slack alerting with conditional routing
  • Google Sheets sync with error handling
  • OpenAI/GPT integration with prompt chaining
  • Schedule-triggered digest workflows
  • And more — all documented, all importable

One purchase, instant download, no subscription.


What's the trickiest filter condition you've had to build in n8n? Drop it in the comments — I'll help debug it.

Top comments (1)

Collapse
 
pirateprentice profile image
Pirate Prentice

What's the most useful filter condition you've set up in n8n? I find people reach for the IF node when Filter is actually cleaner for multi-condition setups. The "match all vs match any" toggle is a hidden gem. Drop your use case below! 👇