Nodes/ComfyUI JMNodes/JMSWitchablePrompt
ComfyUI Node

JMSWitchablePrompt

Switch Any Prompt Fragment On or Off From a Boolean

By JustinMatters·Created 2 years ago·Updated 2 years ago· 0
JMSWitchablePrompt
    • STRING
    prompt
    boolean_switchfalse

    Switchable Prompt JM is the node that makes the JMNodes trick visible. You give it a chunk of prompt text and a boolean, and it does one of two things: pass the text through, or hand you an empty string. Nothing in between. On its own that's a fancy toggle switch. Stack a few of them behind the bits of a counter and you get the real payoff - every combination of your prompt fragments generated systematically, with no randomness and no hand-editing.

    The idea the whole pack is built on: ComfyUI's built-in {option1|option2} syntax picks one option per run, which is great for variety and lousy when you want a complete, reproducible sweep of combinations. Instead of rolling dice, you encode each combination as a binary number and let each bit be one gate. This node is the gate. One per prompt fragment you want to toggle, each wired to one boolean output from Integer to Boolean Values JM.

    How it works

    The logic is dead simple: if the boolean is true, it returns your prompt with newlines collapsed to spaces; if false, it returns "". That newline detail matters more than it looks - it means you can type a fragment across multiple lines in the multiline box and it'll come out as a clean single-line phrase when enabled. The pack's example workflow strings several of these into a Text Concatenate node with ", " as the separator to assemble the final prompt, then feeds that to a CLIPTextEncode. You need that concatenation step yourself; the README calls it out explicitly, and the pack doesn't ship it.

    The inputs and outputs

    Two inputs, both worth knowing:

    • prompt - STRING, multiline, default empty. The fragment that gets gated. Type it here; it only survives if the switch is on.
    • boolean_switch - BOOLEAN, default False. The gate. Wire this to a bit from Integer to Boolean Values JM (via Binary Not JM for negative prompts) or just toggle it by hand.

    The single STRING output carries either your fragment or an empty string - which is the key property: an empty string concatenates away to nothing, so disabled fragments leave no trace in the final prompt. That's what makes the combinatorial assembly work cleanly.

    Installing it

    It lives in ComfyUI JMNodes (JustinMatters/comfyUI-JMNodes), a four-node pack you install through ComfyUI Manager by searching "JMNodes", or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JustinMatters/comfyUI-JMNodes
    

    Restart ComfyUI after cloning. No requirements.txt, no model files, nothing to download - it's string handling plus a boolean. The pack has been static since its single release in early 2025, which suits it: there's not much surface area to improve.

    Common issues

    The traps here are workflow-shaped, not node-shaped. The first is forgetting the concatenation node - you wire a bunch of Switchable Prompts to the sampler and wonder why nothing appears. You have to join their string outputs into one prompt. The second is the False default: a freshly-dropped gate is off, so a fragment silently vanishes until you flip it or feed it a true bit. And remember the order - bits are least-significant-first, so the fragment attached to output 1 of the integer node toggles on every count step while the others move slowly. Match your fragment list to that order consciously and it all clicks.

    CategoryJMNodes

    Inputs (2)

    NameTypeDefaultDescription
    promptSTRING
    boolean_switchBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    STRINGSTRING