Nodes/ComfyUI-QING/文本转布尔丨类型转换
ComfyUI Node

文本转布尔丨类型转换

The exact strings that count as 'true' here

By sheengoa·Created about a year ago·Updated 20 days ago· 16
文本转布尔丨类型转换
    • 布尔
    string

    Most of the time, a boolean in ComfyUI comes from a toggle you click. But sometimes the value arrives as text - read from a file, returned by an API call, spit out by an LLM node, or typed into a prompt template. StringToBool is the bridge: it takes that text and hands you a real BOOLEAN you can plug into a router, a switch, or any node with a boolean input.

    It's one member of the pack's six-way "DataConverter" family (Int↔String, String↔Bool, Bool↔Int, Bool flip). Its Chinese display name is "文本转布尔丨类型转换".

    The one thing to memorize: what counts as true

    The conversion is a strict whitelist. The node strips whitespace, lowercases the input, and returns True only if the result is one of these strings:

    true, 1, yes, on, t, y
    

    That's six tokens, technically, and everything else - including "false", "no", "off", "0" - returns False. Two practical consequences:

    • "TRUE", " Yes ", "ON" all work because of the lowercasing and stripping. Case doesn't bite you.
    • Anything you didn't anticipate is silently False. The list is English-only, which is a real footgun given this pack's Chinese user base: "是" (Chinese for "yes") returns False. If your text value isn't in that exact set, you're getting false whether you meant it or not.

    That's the entire behavior. There's no fuzzy matching, no truthiness tricks. Read the input, hit the whitelist, out comes a boolean.

    Inputs and outputs

    • string (required, STRING) - the text to interpret. The only input.
    • 布尔 (output, BOOLEAN) - the resulting true/false. The output name is the Chinese word for "boolean".

    What to wire it into

    The obvious downstream consumer is a condition router or switch - turn an LLM's one-word verdict into a branch. A common pattern: a text node upstream decides "yes" or "no" (a classifier, a comparison, a file's contents), StringToBool converts it, and a QING_ConditionRouter or any boolean switch picks the path. It also plays nicely with the plumbing layer's value-and-logic philosophy: keep text as text at the boundary where it's produced, convert to logic only where a decision is needed (comfyui-node-plumbing.md covers the routing and gating family these feed).

    One honest note: for a value you're typing by hand, you don't need this node - ComfyUI's own PrimitiveBoolean does that job natively. StringToBool earns its keep only when the string arrives at runtime from somewhere else, which is exactly the case it was built for.

    Installing it

    StringToBool ships in ComfyUI-QING (GAO-SHIQING's 79-node all-in-one pack):

    cd ComfyUI/custom_nodes
    git clone https://github.com/GAO-SHIQING/ComfyUI-QING
    cd ComfyUI-QING
    python install_dependencies.py
    

    Then restart ComfyUI. Or find "ComfyUI-QING" in ComfyUI Manager and click install - same result, no terminal.

    Troubleshooting

    • It returns False when I expect True. Double-check the exact string against the whitelist above. The most common offender is a stray non-English token - the list is true/1/yes/on/t/y and nothing else.
    • Whitespace. Trailing newlines from a multiline text box are handled by the strip() call, so those won't break you. Tabs and internal spaces inside the value will.

    It's a small node with a sharp edge. Once you know the whitelist, it's completely predictable - which is more than you can say for most of this pack's category.

    CategoryQING/数据工具

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    布尔BOOLEAN