Nodes/LF Nodes/Boolean
ComfyUI Node

Boolean

A boolean primitive with history and randomization — the toggle that remembers

By lucafoscili·Created 2 years ago·Updated 2 years ago· 50
Boolean
  • ui_widget
  • boolean
  • boolean_list
booleanfalse
enable_historytrue
randomizefalse
seed42

A boolean is the most boring thing in any programming language and somehow one of the most useful things in a ComfyUI graph. LF_Boolean is the LF Nodes version of that primitive - with two twists that make it worth using over a bare toggle: it remembers, and it can randomize.

The stock ComfyUI way to get a true/false into a workflow is a primitive node or a widget, both of which are one static value forever. LF_Boolean adds a history: when enable_history is on, it saves the value and the date every time the workflow runs. Then randomize - with a seed - randomly picks from the values you've actually used. That turns a static toggle into a poor-man's experiment runner: define true/false, flip randomization on, and batch through both branches of whatever downstream switch you've wired it into.

The inputs that matter

  • boolean - the value itself. The true/false slider on the node. Default false.
  • enable_history - saves past executions (value + date). Keep it on; it's the feature that makes the other two inputs make sense.
  • randomize - when on, the node picks a random previously used value instead of the current one. Note the tooltip's wording: it selects from the history list, not a uniform coin flip, so the values it can choose depend on what you've actually run before.
  • seed - controls that randomness, so a fixed seed gives reproducible picks.

Outputs are boolean and boolean_list (the same value as a one-element list, for list consumers). Wire boolean into any switch - LF's LF_SwitchString, or the boolean input of a conditional - and you're running controlled experiments.

What it's for

This is a workflow-control node, not a data-processing node. The classic setup: a LF_SwitchString choosing between two prompts, driven by a LF_Boolean with randomization on. Every queue gives you a random branch of the A/B test. The history widget is a paper trail of which branch ran when - surprisingly handy when you realize the good results all came from the runs where the toggle was in a certain state.

Installing it

Standard LF Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/comfyui-lf

or ComfyUI Manager → LF Nodes → install → restart. No dependencies, no models. The pack is the frozen legacy repo (development moved to lf-nodes), so this is stable code - but it also won't grow, so check the new repo if you want future primitives.

Where people get burned

  • Randomize needs history. The first run, with an empty history, randomization has nothing to pick from. Run it once or twice with randomize off to seed the history, then flip it on.
  • randomize picks from used values, not freely - so if you want a true 50/50 coin flip across both states, make sure both have actually been used.
  • It outputs a boolean, not a string. If you're feeding it into a text context, run the value through a string conversion or use LF_SwitchString on the other end.

Boring on the surface, quietly useful once you're batching variations. That's the whole pitch.

Category✨ LF Nodes/Primitives

Inputs (5)

NameTypeDefaultDescription
booleanBOOLEANfalseBoolean value.
enable_historyBOOLEANtrueEnables history, saving the execution value and date of the widget.
randomizeBOOLEANfalseRandomly selects a previously used value (must be present in the history list).
seedINT42Seed to control the randomness when 'randomize' is active.
ui_widgetoptKUL_HISTORY[object Object]

Outputs (2)

NameTypeDescription
booleanBOOLEAN
boolean_listBOOLEAN