Random boolean
A weighted coin flip for your workflow
- ui_widget
- boolean
- boolean_list
A plain random True/False switch is a 50/50 coin flip, and sometimes that's not what you want - you might want a prompt variant, a LoRA swap, or a filter to kick in only occasionally, not half the time. LF_RandomBoolean gives you a weighted version: set the odds yourself instead of being stuck at even.
The single input, chance_true, is a percentage from 0 to 100 (default 50) - despite reading like a whole-number setting, it's a float under the hood, so values like 37.5 are valid if you want finer control than integer percentages allow. The node's optional ui_widget renders a progress bar on the canvas showing that probability visually, which is a nice sanity check that you actually set what you think you set. Two outputs come back: boolean, a single True/False result for that run, and boolean_list, the same idea wrapped as a list - useful if something downstream specifically expects a list-typed boolean rather than a scalar.
Feed the boolean output into whatever conditional or switch node picks between two branches in your graph - two prompt variants, two LoRA stacks, on/off for some optional processing step - and you've got a probability-controlled toggle instead of a hardcoded choice.
The boolean_list output is worth a second look if you're doing anything batch-oriented: rather than evaluating the node once per item yourself, some downstream setups expect a list-typed boolean directly, and having it available without an extra conversion step is a small but real convenience. Just don't assume it changes the underlying randomness - it's the same weighted decision, just packaged in the type some nodes insist on.
Installing it. ComfyUI Manager: search "LF Nodes," install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/lucafoscili/lf-nodes, then restart. Pull from that repo - comfyui-lf, what comfy.icu links, is the archived original home of this pack; the author's current work lives at lf-nodes. No models, no heavy dependencies.
Where people get tripped up. The main one: there's no seed input here, so results aren't reproducible run to run by design - if you need a deterministic random choice you can replay, this isn't built for that (look at nodes with an explicit seed field elsewhere in this pack instead, like LF_StringTemplate's randomize option). Second, remember chance_true is the odds of True, not False - setting it to 20 means you'll get True roughly one time in five, False the rest, which is easy to get backwards if you're thinking of it as "how often should this switch off."
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| chance_true | FLOAT | 500–100 | Percentage chance for True output, 0-100. |
| ui_widgetopt | KUL_PROGRESSBAR | [object Object] | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| boolean | BOOLEAN | — |
| boolean_list | BOOLEAN | — |