ComfyUI Node

String to Boolean

Parsing 'yes' / 'no' / 'true' / 'false' like a champ

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
String to Boolean
    • bool_value
    valuefalse

    Text comes in from wildcards, config files, and text-switch nodes saying "true" or "yes" or "1" - and the node you want to feed expects a real BOOLEAN, not a word. String to Boolean bridges that gap, and it's smarter than a naive == "true" check: it understands the whole family of true/false words, case-insensitively. Config strings stop being an obstacle.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. This is a vocabulary lookup in a node - no models, no GPU, nothing to install beyond the pack.

    How it works

    One required input:

    • value - the STRING to interpret (default "false", single-line)

    One output: bool_value - a proper BOOLEAN.

    The interpretation rules, from the source:

    • True: "true", "yes", "1", "on" - all case-insensitive, whitespace trimmed
    • False: "false", "no", "0", "off", and empty string ""
    • Anything else non-empty (say "banana"): True

    That last rule is the one to remember. It's a "anything that isn't an explicit false word counts as true" policy, mirroring how the pack's Type Converter handles strings. It's forgiving, which is usually what you want from config parsing, but it means "maybe" quietly becomes True.

    Where you'll use it

    • Turning config or wildcard output into real logic. If a text file or a switch hands you "yes"/"no", convert it here and wire the boolean into a Logic Gate or conditional string node.
    • Feeding boolean consumers. Many nodes in the ecosystem accept a BOOLEAN input; if yours only has a string (e.g. a flag read from a file), this is the adapter.
    • Pairing with Text Compare - if you have more complex string logic, compare first and convert the result, or convert the raw string for simpler cases.

    Installing it

    Whole pack, one install. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. Requirements (numpy, torch, opencv-python) are already in a stock ComfyUI install; no model downloads. Don't mix it up with cubiq's "ComfyUI Essentials" in Manager's search - different pack, in maintenance mode.

    Gotchas

    • Unknown strings default to True. If you typo "flase", you get True, not an error. The node never fails - it just guesses. For strict parsing, validate upstream.
    • Whitespace is trimmed and matching is case-insensitive, so " YES " works - but the comparison happens on the whole string, so "yes please" is not "yes" and falls through to the True-default.
    • "1.0" is not recognized as true (only bare "1" is) - if you're parsing float-looking flags, convert to float and bool it separately.
    • It's a small, quiet pack; this node is simple enough that its source is the documentation.
    CategoryDebugPadawan/Conversion

    Inputs (1)

    NameTypeDefaultDescription
    valueSTRINGfalse

    Outputs (1)

    NameTypeDescription
    bool_valueBOOLEAN