n8n Switch node: route items to many outputs
Updated 2026-10-21 · 5 min read
The n8n Switch node routes items to more than two outputs. It works like the If node, but instead of true and false you define as many routes as you need: one per order status, one per region, one per event type. This page explains both modes, every option, and the patterns that keep Switch-heavy workflows readable.
Two modes
| Mode | You define | Best for |
|---|---|---|
| Rules | One condition per output, built in the UI | Readable routing on a few fields |
| Expression | One expression returning an output index | Routing computed from data, many outputs |
Both evaluate each item on its own. Ten incoming items can go out of four different outputs in the same run.
Rules mode
Each Routing Rule is a condition built with the same data types and operators as the If node: String (equals, contains, starts with, regex…), Number, Date & Time, Boolean, Array and Object. The full list is on the Switch docs. Every rule creates one output, in order: rule 1 is output 0, rule 2 is output 1, and so on.
Turn on Rename Output in a rule to give its output a name. A canvas with outputs called paid, refunded and failed is much easier to follow than 0, 1, 2.
Options
| Option | Effect |
|---|---|
| Fallback Output | None (default) ignores unmatched items; Extra Output adds an output for them; Output 0 sends them to the first rule's output |
| Ignore Case | Compare strings without case |
| Less Strict Type Validation | Try to convert values to the operator's type |
| Send data to all matching outputs | Off: item goes to the first matching output. On: item goes to every matching output |
Fallback Output: Extra Output is worth turning on almost always. Unmatched items silently disappearing is the most common Switch bug: a new event type appears in production and nothing happens.
Expression mode
Set Number of Outputs, then write an Output Index expression that returns a number from 0 to that count minus one.
Route by a lookup table:
{{ ({ paid: 0, refunded: 1, failed: 2 })[$json.status] ?? 3 }}
With Number of Outputs set to 4, unknown statuses go to output 3, which works as the fallback.
Route by a computed value:
{{ $json.total >= 1000 ? 0 : $json.total >= 100 ? 1 : 2 }}
Expression mode keeps the node compact when there are many routes, but the canvas won't show what each output means. Add a sticky note or rename the nodes after each output.
Examples
Webhook event router
One Webhook node receives all events from a service, a Switch node routes them:
| Rule | Value | Operator | Compare to | Output name |
|---|---|---|---|---|
| 1 | {{ $json.body.type }} |
String is equal to | invoice.paid |
invoice_paid |
| 2 | {{ $json.body.type }} |
String is equal to | invoice.payment_failed |
payment_failed |
| 3 | {{ $json.body.type }} |
String starts with | customer. |
customer |
| Fallback | Extra Output → log only |
Priority tiers
Number rules on {{ $json.amount }}: greater than or equal to 1000, greater than or equal to 100, everything else as fallback. Leave Send data to all matching outputs off, so a 5000 order goes only to the first tier, not to all of them.
Fan-out on purpose
Turn Send data to all matching outputs on when one item should trigger several independent actions, for example "notify sales if plan = enterprise" and "notify finance if amount > 1000". An item that meets both conditions goes to both outputs.
Switch vs If vs Filter
| Situation | Node |
|---|---|
| Yes/no decision | If |
| Three or more mutually exclusive routes | Switch (Rules) |
| Many routes computed from data | Switch (Expression) |
| Keep only matching items | Filter |
| Same item to several routes | Switch with Send data to all matching outputs |
Chaining If nodes three deep to emulate a Switch is a common pattern in imported workflows. It works, but each extra If adds a branch to reason about. Replacing the chain with one Switch is usually the first cleanup after a migration.
Joining routes back
When some routes should continue into shared nodes, connect their outputs to the same next node, or use a Merge node if you need to combine data from several routes. Keep in mind that only outputs that received items run their branches.
From Pipedream Switch and Parallel
Pipedream has two branching operators (Switch, Parallel):
| Pipedream | Behavior | n8n |
|---|---|---|
| Switch | Single path: the first matching case runs | Switch, Rules mode, "Send data to all matching outputs" off |
| Parallel | Multi-path: all matching branches run | Switch with "Send data to all matching outputs" on, or several connections from one node |
| Default case | Runs when nothing matches | Fallback Output: Extra Output |
In a Pipedream export, the steps inside switch branches are stored in the deployments field of each workflow file, not in the main step list. Our converter reads them and tries to rebuild the routes as Switch nodes, but every workflow with branches is marked for manual review: we don't promise that branch conditions convert automatically, so check each one after import. The full mapping is in Pipedream control flow to n8n.
Run your export through the free report to see which workflows have branches before you start. The report and 1 workflow are free. Full export: $3 per workflow, $19 minimum — coming soon. Code steps that do their own routing can be checked one by one with the code step checker.
Not affiliated with Pipedream or n8n.
FAQ
- What is the difference between Rules and Expression mode in the n8n Switch node?
- Rules mode gives each output its own condition, built with the same comparisons as the If node. Expression mode has one expression that returns the output index as a number.
- What happens to items that match no rule?
- By default they are ignored. Set Fallback Output to Extra Output to send them to a separate output, or to Output 0 to send them with the first rule's matches.
- Can one item go to several outputs?
- Yes. Turn on Send data to all matching outputs. By default an item goes only to the first output whose rule matches.
- How many outputs can the Switch node have?
- In Rules mode, one per routing rule (plus an optional fallback). In Expression mode you set Number of Outputs yourself.
Related
Sources
- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.switch
- https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.if
- https://docs.n8n.io/build/flow-logic/split-with-conditionals
- https://pipedream.com/docs/workflows/building-workflows/control-flow/switch
- https://pipedream.com/docs/workflows/building-workflows/control-flow/parallel