π° For Loop ToBoolNode - v1 /l
Anything to a BOOLEAN, with an invert switch β the loop's truth-teller
- value
- BOOLEAN
The For Loop machinery doesn't natively understand "is there still work to do?" as anything other than a BOOLEAN. That's what For Loop ToBoolNode exists to produce: it takes any value and tells you, as a clean true/false, whether it's "something" or "nothing." Then the loop's close node can decide whether to run one more pass.
It's a type coercion node with a good attitude - and it's genuinely load-bearing, because the loop's While-Close internally uses exactly this conversion when it turns the remaining counter into a keep-going condition.
How it works
Feed value (any type), get a BOOLEAN. The conversion rules are sensible and worth knowing:
- A tensor counts as "true" if it has any non-zero element - so an all-black mask or an empty-ish latent is
False, anything with actual signal isTrue. That makes it useful for "is there a mask here?" checks, not just loop counters. - For plain Python values it uses truthiness: numbers, non-empty strings, non-empty lists β true;
0,"",[]β false. - For things that can't be converted at all (weird custom objects), it defaults to
Truewith a shrug - the source code's own comment is literally "I dunno, I'm not a Python programmer."
The invert toggle (default off) flips the result, which is how you write "keep looping until X" instead of "while X."
Inputs: value (*), optional invert (BOOLEAN). Output: BOOLEAN.
Using it
Mostly inside loops: wire a counter or a condition check into value, and feed the output into For Loop While Close's condition. Outside loops, it's a handy universal truthiness gate - combine with Is Equal ? or Is Empty ? and you have the primitive blocks for real branching in ComfyUI, where core gives you almost none of that for free.
Installing it
Ships in the MaraScott pack: ComfyUI Manager β search "MaraScott" β Install β restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MaraScott/ComfyUI_MaraScott_Nodes
Then restart. It's a one-node utility in a pack that pins transformers==4.37.2 and installs opencv-python, numba and blend_modes - small node, chunky install, same as every other sibling.
Common issues
Two gotchas. First, tensor semantics: an image tensor that's all black (all zeros) reads as False, which can genuinely surprise you if you expected "an image arrived, therefore true." For mask-vs-none checks that's actually what you want, but for image presence checks it isn't - test before you trust. Second, the "can't convert β defaults to true" fallback means unrecognized objects always look "truthy"; if a node upstream returns a type ToBoolNode doesn't know, you'll silently get True. And remember invert is a separate input, not a right-click menu item - wire it from a BOOLEAN node or toggle it in the widget.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | * | β | |
| invertopt | BOOLEAN | false | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | β |