Nodes/ComfyUI-ZFRNodes/Convert To Boolean
ComfyUI Node

Convert To Boolean

Teaching ComfyUI to Understand \"Yes\"

By zfrsgtcu·Created 3 months ago·Updated 13 days ago· 32
Convert To Boolean
  • input
  • output

Branching on what an LLM said

The most powerful ComfyUI workflows are conditional: ask a model whether to run the upscale, then take one path or the other. Switch and condition nodes want a BOOLEAN input, but the value you actually have is text - an LLM answer of "true", an API flag of "1", a JSON field that says "off". The graph won't route a STRING wire into a BOOL port, so the branch just never fires. Convert To Boolean is the node that makes the yes-or-no decision actually connect.

It's the smallest of the four nodes in the ComfyUI-TypeConverters pack, and in a sense the bravest: booleans are the type with the most ambiguous textual forms, so it has to make real judgment calls. The README's example - JSON Extract → Convert To Boolean → Condition Switch - is the canonical wiring, and it's the pattern you'll find in most LLM-driven graphs.

How it works

The conversion is a three-step ladder:

  • If the input is already a BOOL, it passes through untouched.
  • Numbers follow Python's rule: 0False, anything nonzero → True. Yes, that includes -3.
  • Text is matched case-insensitively: "true", "1", "yes", "y", "on"True; "false", "0", "no", "n", "off"False.

Here's the judgment call: anything unrecognized - including None and empty strings - becomes False. The fallback is "no," not "error." So "banana" is False, and so is a missing value. That's usually the safe direction for a conditional, but it does mean an LLM that answers "yes, definitely, please upscale" (rather than a clean "yes") quietly takes the false branch. If your branch never fires, check the raw text before blaming the node.

The inputs and outputs that matter

  • input (ANY) - accepts any wire, so you can hang it right off an LLM or JSON extractor without adapters.
  • output (BOOL) - a clean boolean for switch, condition, and gate nodes.

Reach for it when a text answer needs to become a branch, or when you're building dynamic workflows where a model's verdict steers the pipeline.

Installing it

Same story as the rest of the pack. ComfyUI Manager: search "ComfyUI-TypeConverters" and install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/zfrsgtcu/ComfyUI-TypeConverters

Restart and it's under zfr-nodes. No models, no dependencies, single Python file - about as low-risk an install as custom nodes get.

The trap to watch

The False fallback is the whole gotcha. If a conditional switch seems to ignore what the model said, the model probably didn't say a word the node recognizes. Nudge your LLM prompt to reply with exactly true or false - that's the dialect this node speaks fluently, and the one-liner in your prompt beats debugging a silent wrong branch.

Categoryzfr-nodes

Inputs (1)

NameTypeDefaultDescription
input*

Outputs (1)

NameTypeDescription
outputBOOLEAN