Overview
This lesson is part of the n8n AI Automation - Zero to Hero course, Section: 3. Deep Dive Concepts.
Watch the video above for the full tutorial, or read the written guide below.
What is the Switch node and how does it create multiple paths in an n8n workflow?
The Switch node routes each incoming item to a named output branch based on configurable matching rules, replacing a chain of stacked IF nodes with a single, readable configuration. While the IF node produces only two outputs, true or false, the Switch node supports four or more branches simultaneously. In this lesson it evaluates order_status and splits 100 orders into pending, processing, canceled, and refunded streams in one step.
How to build a multi-branch order-routing workflow in n8n
The Manual Trigger node starts the workflow for testing, with a Schedule Trigger recommended for daily production runs at a fixed time. A Google Sheets node follows, configured with the "Get Rows" operation pointing to the mock orders spreadsheet, which returns all 100 records as a list of JSON objects. Every record shares seven properties: row number, order ID, first name, last name, customer email, order status, and order date. In n8n, even a single returned record is wrapped in a list because every node expects a list of items as input.
The Switch node connects directly after Google Sheets. Each routing rule compares $json.order_status against a fixed string value: "pending", "processing", "canceled", or "refunded". Dragging the field from the item properties panel into the value slot auto-converts it from fixed text to expression mode, where anything inside double curly braces is evaluated as JavaScript. Each rule maps to a renamed output branch, such as "pending orders" or "processing orders". Renaming outputs is a best practice: without it, the canvas labels branches only as output 0, 1, 2, and 3, forcing you to reopen the Switch node to understand what each branch does. Two additional options improve reliability: "Fallback output" handles items that match no rule (left blank to silently drop unmatched statuses like "shipped" or "delivered"), and "Ignore case" prevents routing failures when source data uses inconsistent capitalization.
Each branch connects to a specific action node based on business need. The pending-orders branch connects to an Amazon SES node that sends an alert email to the customer service team, with the subject built dynamically using $json.order_id as an expression. The processing-orders branch connects to a Slack node that posts to a dedicated high-priority channel so the operations team can expedite shipping without waiting for email. The canceled and refunded branches both connect into the same Amazon SES node and the same Slack node, because both statuses require identical downstream actions: a finance-team email and a Slack notification to the canceled-and-refunded channel. n8n allows multiple upstream branches to feed a single downstream node, so no duplication is needed.
Key Takeaways
- The Switch node replaces stacked IF nodes when three or more distinct conditions exist, producing one named output branch per rule from a single configuration panel.
- Routing rules use
$json.<property>expressions, auto-generated by dragging a field from the item panel, to evaluate any property of the current item against a fixed value. - Renaming each output branch directly inside the Switch node, for example "pending orders", prevents canvas confusion where unnamed branches default to "output 0", "output 1", etc.
- The "Ignore case" option makes string comparisons case-insensitive, preventing routing failures when order status values are entered with inconsistent capitalization in the source sheet.
- Multiple upstream branches can share a single downstream action node, so canceled orders and refunded orders can both trigger the same email node and Slack node without duplicating either.
Related Lessons
- Lesson 12: How to Use Merge Node in n8n | Combine Data Like a Pro
- Lesson 13: How to Use Set Node in n8n | Edit Fields Node | Add, Edit, Clean Data
- Lesson 14: How to Use Aggregate Node in n8n | Combine & Summarize Data
- Lesson 15: How to Use Remove Duplicates Node in n8n | Clean Your Data Fast
- Lesson 16: How to connect Google Forms & Webhook Node in n8n | Google Forms Integration
Next Steps
Continue your n8n journey with the full n8n AI Automation - Zero to Hero course.