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:
Cache Set,Roboflow Asset Library Attributes,MoonshotAI Kimi,Path Deviation,Image Blur,SmolVLM2,Keypoint Detection Model,Overlap Filter,SIFT Comparison,Reference Path Visualization,PTZ Tracking (ONVIF),Event Writer,Slack Notification,SAM2 Video Tracker,Halo Visualization,CLIP Embedding Model,Image Stack,VLM As Classifier,Clip Comparison,Google Gemma,Bounding Rectangle,Object Detection Model,Dot Visualization,Qwen 3.6 API,Label Visualization,Background Color Visualization,Llama 3.2 Vision,Email Notification,SAM 3 Interactive,Rate Limiter,Velocity,Pixelate Visualization,OpenAI-Compatible LLM,Qwen3-VL,Google Gemini,JSON Parser,Anthropic Claude,Track Class Lock,Cache Get,OpenAI,Trace Visualization,Llama 3.2 Vision,Detection Event Log,ByteTrack Tracker,Clip Comparison,Camera Focus,OpenAI,Qwen3.5,GLM-OCR,PLC ModbusTCP,Buffer,QR Code Detection,SIFT Comparison,CSV Formatter,Webhook Sink,MQTT Writer,Image Contours,Motion Detection,Local File Sink,Google Gemini,MoonshotAI Kimi,Polygon Visualization,Dimension Collapse,SIFT,Classification Label Visualization,First Non Empty Or Default,Multi-Label Classification Model,Instance Segmentation Model,Keypoint Detection Model,Template Matching,Keypoint Visualization,Instance Segmentation Model,Icon Visualization,Seg Preview,Dynamic Crop,Stability AI Inpainting,Detections Transformation,Bounding Box Visualization,Polygon Zone Visualization,Stability AI Outpainting,Crop Visualization,BoT-SORT Tracker,Multi-Label Classification Model,Continue If,Image Convert Grayscale,Byte Tracker,Mask Visualization,Halo Visualization,Delta Filter,Expression,Detection Offset,Detections Stitch,Distance Measurement,Barcode Detection,SORT Tracker,PLC EthernetIP,Anthropic Claude,Text Display,Morphological Transformation,VLM As Classifier,Inner Workflow,Overlap Analysis,Roboflow Dataset Upload,VLM As Detector,Detections Consensus,Object Detection Model,Detections Filter,Ellipse Visualization,Detections Merge,Keypoint Detection Model,SAM3 Video Tracker,Time in Zone,SAM 3,Size Measurement,Circle Visualization,Semantic Segmentation Model,Path Deviation,Twilio SMS Notification,Email Notification,S3 Sink,Camera Focus,Environment Secrets Store,Identify Changes,Byte Tracker,Single-Label Classification Model,SAM 3,Image Slicer,LMM For Classification,Dominant Color,OCR Model,Mask Area Measurement,Heatmap Visualization,Switch Case,OpenAI,Google Gemma API,Stitch Images,Identify Outliers,Time in Zone,Morphological Transformation,Single-Label Classification Model,EasyOCR,YOLO-World Model,Current Time,Blur Visualization,Stitch OCR Detections,Moondream2,Detections List Roll-Up,Florence-2 Model,Google Gemini,Corner Visualization,OpenRouter,Detections Stabilizer,Pixel Color Count,Model Comparison Visualization,SAM 3,Model Monitoring Inference Aggregator,Google Vision OCR,Image Threshold,Byte Tracker,Instance Segmentation Model,LMM,Single-Label Classification Model,Polygon Visualization,Segment Anything 2 Model,Time in Zone,Stability AI Image Generation,Line Counter,Line Counter Visualization,CogVLM,Mask Edge Snap,Relative Static Crop,Qwen3.5-VL,Per-Class Confidence Filter,Grid Visualization,Image Preprocessing,Property Definition,Stitch OCR Detections,Gaze Detection,Anthropic Claude,OPC UA Writer Sink,Color Visualization,Dynamic Zone,Detections Combine,Triangle Visualization,Data Aggregator,QR Code Generator,Roboflow Dataset Upload,Qwen 3.5 API,Absolute Static Crop,Contrast Enhancement,Background Subtraction,Multi-Label Classification Model,OC-SORT Tracker,OpenAI,Image Slicer,Semantic Segmentation Model,Qwen-VL,Florence-2 Model,Perspective Correction,Twilio SMS/MMS Notification,Roboflow Vision Events,Microsoft SQL Server Sink,Cosine Similarity,Perception Encoder Embedding Model,Instance Segmentation Model,Depth Estimation,Roboflow Custom Metadata,Contrast Equalization,Camera Calibration,Detections Classes Replacement,VLM As Detector,Qwen2.5-VL,Line Counter,Object Detection Model - 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"
]
}