n8n Switch node: route items to many outputs
Updated 2026-10-21 · 5 min read
- The Switch node routes items to more than two outputs, one per rule or by expression.
- Items that match no rule are ignored by default. Set Fallback Output to Extra Output.
- By default, an item goes only to the first output whose rule matches.
The n8n Switch node routes items to more than two outputs. It works like the If node, but without the fixed 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 and every option. It also shows patterns that keep workflows with many Switch nodes 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 that returns an output number (index) | Routing computed from data, many outputs |
Both modes check each item on its own. Ten incoming items can leave through four different outputs in the same run.
Rules mode
Each Routing Rule is a condition. It uses 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 in 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. Outputs called paid, refunded and failed are much easier to follow on the canvas than 0, 1, 2.
Options
| Option | Effect |
|---|---|
| Fallback Output | None (default) ignores items that match no rule; Extra Output adds an output for them; Output 0 sends them to the first rule's output |
| Ignore Case | Compares strings without caring about upper and lower case |
| Less Strict Type Validation | Tries to convert values to the operator's type |
| Send data to all matching outputs | Off: an item goes to the first matching output. On: an item goes to every matching output |
Turn on Fallback Output: Extra Output almost always. The most common Switch bug is unmatched items that silently disappear. A new event type appears in production, and nothing happens.
Expression mode
Set Number of Outputs. Then write an Output Index expression. It must return a number from 0 to that count minus one.
Route by a lookup table:
{{ ({ paid: 0, refunded: 1, failed: 2 })[$json.status] ?? 3 }}
Here Number of Outputs is 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
Set 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. Then a 5000 order goes only to the first tier, not to all of them.
Fan-out on purpose
Sometimes one item should start several independent actions. For example, "notify sales if plan = enterprise" and "notify finance if amount > 1000". Turn Send data to all matching outputs on. An item that meets both conditions then goes to both outputs.
Switch vs If vs Filter
| Situation | Node |
|---|---|
| Yes/no decision | If |
| Three or more routes, each item takes only one | 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 |
Imported workflows often chain If nodes three deep to imitate a Switch. That works, but each extra If adds a branch to think through. Replacing the chain with one Switch is usually the first cleanup after a migration.
Joining routes back
Some routes should continue into shared nodes. Connect their outputs to the same next node. If you need to combine data from several routes, use a Merge node. Keep in mind: only outputs that received items run their branches.
From Pipedream Switch and Parallel
Pipedream has two branching operators, Switch and 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 sit in the deployments field of each workflow file. They are not in the main step list. Our converter reads them and tries to rebuild the routes as Switch nodes. But it marks every workflow with branches 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.
Before you start, run your export through the free report to see which workflows have branches. The report and 1 workflow are free. Full export: $3 per workflow, $1 each after 50, $19 minimum, one-off. Code steps that do their own routing can be checked one by one with the Code node compatibility check.
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.
Sources (5)
- 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