Switch String
A boolean switch for text that doesn't make you squint at wires
- ui_widget
- string
- string_list
Sometimes your workflow needs to pick between two pieces of text based on a condition - two prompts, two negative prompts, two filenames, two API strings. You could string together a switch node from another pack or wrestle with a Python script node, but LF_SwitchString does the narrow thing cleanly: on_true, on_false, and a boolean condition. If the boolean is true you get on_true; otherwise on_false. That's the whole node, and honestly that's why it's good.
Where it earns its keep is in batch and A/B workflows. Pair it with a primitive that flips per run (or a LF_Boolean node with randomization enabled) and you can toggle between two prompt styles, two seed strings, or a "high detail / low detail" pair without editing the graph. Same idea as the classic two-way text switch in other packs, but this one ships with a progress-bar-style widget (KUL_PROGRESSBAR) and keeps the LF Nodes look.
The inputs that matter
on_true/on_false- both are multiline strings, so you can drop multi-line prompts in rather than fighting a single-line field.boolean- the condition. Defaults to false, so out of the box you'll geton_falseuntil you wire something in. Feed it from any boolean source: aLF_Booleannode, a comparison result, or an LLM's structured output viaLF_GetValueFromJSON.
Outputs are string (the chosen value) and string_list (same thing as a list, for nodes that want lists). Wire string into your prompt encoder or filename builder and move on.
A small reality check
This is one of those nodes where the name sounds like it does more than it does. It's not a text router, it doesn't support more than two branches, and the condition can't be a string comparison - it must be an actual boolean. If you need multi-way routing, you chain several of these or grab a multi-switch node from a different pack. For exactly two options, though, this is the node.
Installing it
Standard LF Nodes install:
cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/comfyui-lf
or ComfyUI Manager → LF Nodes → install → restart. No dependencies, no models.
Where people get burned
- Forgetting the default.
booleanstarts as false, so the first time you wire this in and seeon_falsecome out, it's not broken - you just haven't connected (or flipped) the condition yet. - Multiline strings and the empty default: if
on_truestarts empty and you flip the boolean, you get an empty string silently. Fill both branches before you queue. - The pack itself is legacy - migrated to lf-nodes in early 2025 - so treat this as stable, finished code. It won't gain features, and it doesn't need to.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| on_true | STRING | Value to return if the boolean condition is true. | |
| on_false | STRING | Value to return if the boolean condition is false. | |
| boolean | BOOLEAN | false | Boolean condition to switch between 'on_true' and 'on_false' values. |
| ui_widgetopt | KUL_PROGRESSBAR | [object Object] | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |
| string_list | STRING | — |