Switch Case¶
Class: SwitchCaseBlockV1
Source: inference.core.workflows.core_steps.flow_control.switch_case.v1.SwitchCaseBlockV1
Route workflow execution to one of several branches by matching an input value against a set of case values, similar to a switch-case statement in programming, enabling multi-way branching, value-based routing, and decision trees without chaining multiple Continue If blocks.
How This Block Works¶
This block compares a single input value against the keys of a case mapping and directs execution to the step associated with the first matching case. The block:
- Takes a
valueinput (typically a selector referencing a workflow input or a step output, e.g. a classification result) and converts it to a string - Looks the string up in the
casesmapping, where each key is a case value and each value is the step to execute when that case matches (e.g.{"red": "$steps.on_red", "blue": "$steps.on_blue"}) - If
case_insensitiveis enabled, the comparison ignores letter case - If a case matches, execution continues to that case's step and all other branches terminate
- If no case matches, execution continues to the steps listed in
default_next_steps - If no case matches and
default_next_stepsis empty, the branch terminates
Because the input value is converted to a string before matching, non-string values match their
string representation: True matches the key "True", 1.0 matches "1.0" (not "1"), and a
missing/None value matches "None". Each target step may appear at most once across cases and
default_next_steps — to route several case values to the same logic, point each case at its own
step or normalize the value upstream (e.g. with an Expression block).
Common Use Cases¶
- Routing by classification result: Send images down different processing paths based on the top class predicted by a classification model (e.g. "damaged" → alert branch, "ok" → logging branch, anything else → default review branch)
- Mode-based pipelines: Use a workflow input parameter (e.g.
$inputs.mode) to select between alternative processing branches at runtime without editing the workflow - Multi-way alerting: Route to different notification blocks (email, Slack, webhook) depending on a severity or category value computed earlier in the workflow
- Replacing chained conditions: Collapse a ladder of Continue If blocks comparing the same value against different constants into a single, easier-to-read block
Connecting to Other Blocks¶
This block controls workflow execution flow and can be connected:
- After classification or detection blocks to branch on predicted classes, counts, or other prediction properties (often via a Property Definition or Expression block that extracts the value to switch on)
- After workflow inputs to select a branch from a runtime parameter
- Before any downstream blocks (models, notifications, sinks) that should only run for a specific case — each case target becomes the head of its own execution branch
- With a default branch wired via
default_next_stepsto handle unmatched values, or left empty to simply stop when nothing matches
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/switch_case@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
value |
Union[bool, float, int, str] |
Value to match against the case keys. Typically a selector referencing a workflow input or a step output (e.g. $inputs.mode or $steps.classifier.top). The value is converted to a string before comparison, so booleans match keys 'True'/'False', 1.0 matches '1.0' and a None value matches 'None'.. | ✅ |
case_insensitive |
bool |
When enabled, case values are matched ignoring letter case (e.g. value 'RED' matches case key 'red').. | ❌ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Switch Case in version v1.
- inputs:
Crop Visualization,Image Slicer,Detection Event Log,Roboflow Dataset Upload,ByteTrack Tracker,Instance Segmentation Model,Google Gemini,Classification Label Visualization,Mask Edge Snap,Dynamic Crop,Per-Class Confidence Filter,Detections Transformation,SAM 3 Interactive,Time in Zone,Velocity,Image Slicer,Absolute Static Crop,Detections Classes Replacement,Overlap Analysis,Template Matching,Current Time,Expression,Cache Get,Pixel Color Count,Roboflow Custom Metadata,Multi-Label Classification Model,SIFT Comparison,Mask Area Measurement,Morphological Transformation,Background Subtraction,Line Counter Visualization,BoT-SORT Tracker,Ellipse Visualization,OpenAI,Multi-Label Classification Model,MoonshotAI Kimi,SAM 3,Grid Visualization,PLC ModbusTCP,Bounding Box Visualization,Morphological Transformation,Segment Anything 2 Model,Semantic Segmentation Model,Google Gemma,Perception Encoder Embedding Model,Byte Tracker,Object Detection Model,Motion Detection,Cosmos 3,Overlap Filter,OpenAI,Multi-Label Classification Model,Cosine Similarity,Webhook Sink,VLM As Detector,Path Deviation,Size Measurement,Depth Estimation,Image Preprocessing,OPC UA Writer Sink,Bounding Rectangle,Detections Stabilizer,Single-Label Classification Model,SAM 3,Line Counter,QR Code Detection,Stitch Images,Roboflow Dataset Upload,OpenAI,SAM2 Video Tracker,Qwen3.5,Camera Calibration,Google Vision OCR,OpenAI,QR Code Generator,Florence-2 Model,Polygon Zone Visualization,Qwen3-VL,Detection Offset,Cache Set,Contrast Equalization,SAM3 Video Tracker,VLM As Classifier,Detections List Roll-Up,Clip Comparison,Pixelate Visualization,SORT Tracker,Qwen 3.6 API,PLC Writer,CSV Formatter,Detections Stitch,Track Class Lock,Triangle Visualization,Stability AI Image Generation,Icon Visualization,Dot Visualization,Stability AI Outpainting,Byte Tracker,Keypoint Visualization,Relative Static Crop,Anthropic Claude,PP-OCR,Anthropic Claude,Image Stack,Roboflow Visual Search Classifier,VLM As Detector,OCR Model,SAM 3,GeoTag Detection,PTZ Tracking (ONVIF),Qwen 3.5 API,Halo Visualization,OpenRouter,Frame Delay,Semantic Segmentation Model,Local File Sink,Text Display,Roboflow Asset Library Attributes,Image Threshold,Image Blur,LMM,Inner Workflow,Color Visualization,Gaze Detection,First Non Empty Or Default,Corner Visualization,JSON Parser,S3 Sink,MQTT Writer,Continue If,Qwen-VL,Instance Segmentation Model,CLIP Embedding Model,Google Gemini,Stitch OCR Detections,Slack Notification,Event Writer,Detections Consensus,Identify Outliers,SIFT,Nearest Neighbor Detection Match,Stitch OCR Detections,Google Gemini,Auto Rotate on Edges,Time in Zone,VLM As Classifier,Instance Segmentation Model,Dimension Collapse,Twilio SMS Notification,Single-Label Classification Model,Trace Visualization,Perspective Correction,Seg Preview,Camera Focus,EasyOCR,Google Gemma API,PLC EthernetIP,Property Definition,Object Detection Model,Instance Segmentation Model,OC-SORT Tracker,MoonshotAI Kimi,Distance Measurement,Data Aggregator,Twilio SMS/MMS Notification,Blur Visualization,Path Deviation,LMM For Classification,Polygon Visualization,Model Monitoring Inference Aggregator,Stability AI Inpainting,Image Convert Grayscale,Microsoft SQL Server Sink,Florence-2 Model,Qwen3.5-VL,Barcode Detection,Moondream2,Dominant Color,Clip Comparison,Delta Filter,Dynamic Zone,Mask Visualization,Reference Path Visualization,Email Notification,Polygon Visualization,Roboflow Visual Search,SIFT Comparison,Switch Case,Halo Visualization,SmolVLM2,Environment Secrets Store,Rate Limiter,Keypoint Detection Model,Contrast Enhancement,Llama 3.2 Vision,Detections Combine,GLM-OCR,CogVLM,Byte Tracker,Circle Visualization,Image Contours,Camera Focus,Heatmap Visualization,Line Counter,Roboflow Vision Events,YOLO-World Model,Llama 3.2 Vision,Qwen2.5-VL,OpenAI-Compatible LLM,Label Visualization,Time in Zone,Background Color Visualization,Keypoint Detection Model,PLC Reader,Buffer,Single-Label Classification Model,Model Comparison Visualization,Keypoint Detection Model,Detections Merge,Detections Filter,Object Detection Model,Email Notification,Anthropic Claude,Identify Changes - outputs: None
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Switch Case in version v1 has.
Bindings
-
input
value(*): Value to match against the case keys. Typically a selector referencing a workflow input or a step output (e.g. $inputs.mode or $steps.classifier.top). The value is converted to a string before comparison, so booleans match keys 'True'/'False', 1.0 matches '1.0' and a None value matches 'None'..cases(step): Mapping of case value to the step that should execute whenvaluematches it, e.g. {"red": "$steps.on_red", "blue": "$steps.on_blue"}. Each target step may appear at most once acrosscasesanddefault_next_steps..default_next_steps(step): Steps to execute when no case matches. Leave empty to terminate the branch when nothing matches..
-
output
Example JSON definition of step Switch Case in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/switch_case@v1",
"value": "$steps.classifier.top",
"cases": {
"blue": "$steps.on_blue",
"red": "$steps.on_red"
},
"case_insensitive": false,
"default_next_steps": [
"$steps.fallback"
]
}