Switch Float
A ternary if/else for float values
- ui_widget
- float
- float_list
ComfyUI has a boolean type and it has floats, but the moment you want "use this value when the flag is true, that value when it's false," you're suddenly wiring switches or rebuilding conditionals. LF_SwitchFloat is the two-line ternary compressed into a node: on_true, on_false, and a boolean to pick between them. The float that comes out is whichever side the boolean lands on. That's the entire job, and it's the right size for the job.
The inputs are self-explanatory: on_true and on_false are the two float values (both default to 0), boolean is the condition - wire it from any boolean-producing node, or toggle it by hand. Output is float plus a float_list variant for when a downstream node wants the value as a list. It lives in the Logic category because it's pure control flow: nothing generated, nothing processed, just a decision.
Where this earns its place is parameter routing. A few genuinely common patterns:
- CFG or strength switching. Same workflow, two different values for different runs - flip a boolean and
on_true/on_falsepick the value, instead of editing a number widget every time. - Conditional scheduling. Chain it off a comparison node or the
is_landscapeoutput ofLF_ResolutionSwitcher- landscape gets one denoise value, portrait gets another. - Batch variation. Wire the boolean to a random or seed node and each run randomly picks between two strengths. It's a poor man's sampler switch.
The honest caveat: it switches between two literal values, not two dynamic inputs. The on_true/on_false fields are fixed numbers you set on the widget - if you want to switch between two values coming from other nodes, you're looking for a different (primitive-switch) node. This one is for the "two constants, one flag" case, which is honestly most of the case. There's also no third "unset" state - if the boolean isn't connected, it defaults to false and you get on_false. That default surprises people exactly once: they connect nothing, see on_false come out, and think it's broken.
It's a small node and it says so - but it's a good example of what LF Nodes does well: taking the micro-tasks you'd otherwise hand-wire and making them first-class graph citizens, with a widget that shows the value instead of hiding it in a connection.
Install is the pack standard: ComfyUI Manager → "LF Nodes", or git clone https://github.com/lucafoscili/comfyui-lf into custom_nodes, then restart. And the note that follows every node here: comfyui-lf is frozen in legacy mode (fully functional), with active development in lucafoscili/lf-nodes where the same switch lives.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| on_true | FLOAT | 0.00 | Value to return if the boolean condition is true. |
| on_false | FLOAT | 0.00 | Value to return if the boolean condition is false. |
| boolean | BOOLEAN | false | Boolean condition to switch between 'on_true' and 'on_false' values. |
| ui_widgetopt | KUL_PROGRESSBAR | [object Object] | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| float | FLOAT | — |
| float_list | FLOAT | — |