Nodes/honda-nodes/πŸ”€ Text Conditional Switch
ComfyUI Node

πŸ”€ Text Conditional Switch

One prompt socket, two strings, a boolean in charge

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ”€ Text Conditional Switch
    • Output
    β—„conditionβ€”β–Ί
    β—„text_aβ€”β–Ί
    β—„text_bβ€”β–Ί

    Sooner or later every workflow grows a fork in the road: prompt A for the daylight version, prompt B for the night version, or one string for the base pass and another for the detail pass. Without a switch you duplicate everything downstream and keep the two halves manually in sync, which works right up until you change one and forget the other.

    πŸ”€ Text Conditional Switch is the smallest possible answer to that: two strings in, a boolean decides which one comes out, one socket out. It's two lines of Python wearing a node costume, and that's the point.

    What it is

    Part of Avaray/honda-nodes - a pack that's mostly about metadata and file plumbing, with a text/logic corner bolted on. This node is the A/B selector from that corner. You give it condition, text_a and text_b; it returns text_a when condition is true and text_b when it's false. There's a single output, Output, typed STRING, ready to drop into a CLIP Text Encode, a concatenate node, a filename builder, or a print node.

    The distinction that matters, and it's the one people get wrong: this is an A/B switch, not a fallback switch. It has a selector and it obeys it. It will not look at your inputs and pick "whichever one is actually plugged in" - that's a different node shape (rgthree's Any Switch is the canonical fallback), and reaching for this one when you wanted fallback behaviour gets you an empty prompt and twenty minutes of confusion.

    The inputs you actually touch

    Condition is a BOOLEAN socket, and it's forced to be an input - no toggle you can click in the node. Some source has to feed it. Inside this pack you have a few natural producers: πŸ”€ Text Match emits a Match boolean, Array Includes emits Result, JSON Validate emits Is Valid, and Array For Each emits Is Last if you're doing per-item logic. Outside the pack, ComfyUI's core PrimitiveBoolean gives you a switch you flip by hand, which is the usual way to make this node behave like a manual toggle.

    That's the genuinely nice trick: wire PrimitiveBoolean into Condition, and you've got a labelled toggle sitting on your canvas that re-points a whole downstream branch without you rewiring anything.

    Text A (True) and Text B (False) are multiline text boxes. Type straight into them, or right-click β†’ convert to input and pipe in strings from elsewhere. Combination is normal: one branch is a hand-typed negative prompt, the other is a file reader's output.

    Why you'd keep it instead of just muting a node

    Honest answer: for a static choice you make once, two CLIP Text Encodes with one bypassed is simpler and you don't need this node at all. The switch earns its place when the decision is computed - driven by a match, a validation result, an array position - or when the condition is a one-widget change you'll flip a hundred times and you'd rather not touch the graph. One selector, one downstream branch, no duplicated sampler stacks.

    Install

    It ships in the same pack as the rest of the Honda nodes, so you install once and get the whole family:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py
    

    Or through ComfyUI Manager: Extensions β†’ Node Manager β†’ Node Pack β†’ search Honda Nodes β†’ Install β†’ restart ComfyUI. The installer fetches jq and the author's ime binary into the pack's bin/ folder; this node needs neither, but the metadata and image nodes in the pack do, so let it run.

    One compatibility note: honda-nodes is written against ComfyUI's V3 node schema (comfy_api.latest) and lists ComfyUI 0.38.0 as its minimum. On an older install the nodes don't show up at all. There's nothing to debug - update ComfyUI.

    Common issues

    The condition socket refuses your typing. By design. Connect a boolean source; if you want a manual switch, use PrimitiveBoolean.

    The node never executes. It's not an output node, so ComfyUI only runs it if something downstream of Output needs it. During setup, wire Output into a Print to Console or text preview and you'll see it fire.

    An empty prompt appears and nothing warns you. If the selected branch is unconnected or blank, you get an empty string back - the node returns result or "", so it never raises, never complains, and your sampler happily generates from nothing. If an image comes out looking like the prompt was ignored, check which branch the condition is actually selecting before you blame the model.

    Wrong branch firing. Almost always the boolean source, not the switch. Print the condition, or print the switch output with a label, and look at the console. Guessing from the picture is slower.

    Category⚑️ Honda Nodes/πŸ”€ Text

    Inputs (3)

    NameTypeDefaultDescription
    conditionBOOLEANIf True, outputs Text A. If False, outputs Text B.
    text_aSTRINGThe text to output if the condition is True.
    text_bSTRINGThe text to output if the condition is False.

    Outputs (1)

    NameTypeDescription
    OutputSTRINGβ€”