Nodes/Vantage-NodesV2/String Switch (VantageV2)
ComfyUI Node

String Switch (VantageV2)

Pick a branch by what the text says

By vantagewithai·Created 15 days ago·Updated 11 days ago· 3
String Switch (VantageV2)
  • input_0
  • value
◄value►
◄conditions[{"operator":"=","value":"","input":0}]►

Text is the one type in ComfyUI everybody already drives - prompts, mode names, filenames, trigger words. String Switch lets the content of a string decide which branch of your graph executes, which is a surprisingly clean way to build a single workflow that fans out into several personalities.

What it does

value takes a STRING. Ordered rules each pair an operator - =, !=, contains, not contains, starts with, ends with - with a constant and a zero-based input index. First match wins and its input_N wildcard socket is the output. Add, delete and reorder rules from the gear in the title bar; the input count grows to cover whatever indices your rules reference.

The matching is case-sensitive and whitespace-preserving. "Portrait" and "portrait " are different strings and neither equals "portrait". Empty strings are legal comparisons. The README is honest about all of this, and it's the same honesty Python gives you - it's doing exactly what it says on the tin.

Because the data inputs are lazy, only the selected branch is executed. Two prompt families behind one switch cost you the winning one, not both. That's the whole reason to use this over Any Switch for text-driven routing.

Rule order is the logic

The README's example is exactly right and worth restating: starts with "portrait" for one branch, contains "landscape" for another - specific first, broad second. Put the vague rule at the top and it eats every value that would have matched below it.

Two things people get caught by:

  • Case. A CLIP Text Encode prompt that begins "Portrait of…" won't match starts with "portrait". If your input case is out of your control, prefer contains and accept that it's looser, or normalise the text before it reaches the node.
  • Trailing whitespace. Prompts get concatenated all the time, and a stray space in front of the word kills a starts with. It's a boring bug that costs ten minutes, every time.

If nothing matches, the output is None. No fallback, no error. A catch-all rule (not contains "", or simply a final broad rule) is worth adding if None would break a required downstream input.

Where you'd use it

The use I'd actually reach for: one workflow, several looks. A string node at the top holds cinematic, product, illustration; three rules send it to three different prompt-enhancement chains or three different checkpoint/is-style loaders. Change three letters and you've changed the entire pipeline, rather than hunting for the right node to bypass.

It's also the natural partner of this pack's Easy Controls, which groups nodes behind toggles - you can drive a string from elsewhere and let the game of "which branch" stay explicit rather than implicit in what's muted.

Output is one socket named value, typed *. Wire it into whatever the winning branch feeds. Careful with the wildcard: nothing checks the type until execution.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/vantagewithai/Vantage-NodesV2.git

Restart ComfyUI, hard-refresh, then search "String Switch" or browse Vantage/Utils. ComfyUI Manager should also carry the pack as Vantage-NodesV2; the clone above is the documented method.

No dependency step - there's no requirements file, and pyproject.toml declares no packages, so everything it imports comes from ComfyUI itself. It does require a recent ComfyUI: the pack uses the current title-button and widget APIs, and this node's rule editor lives in a title-bar dialog. On an old install you'll either miss the node entirely or miss the gear.

When it doesn't behave

None out - check case, whitespace, rule order, and whether the selected socket is connected. In that order, honestly; that's the frequency ranking.

Rules not applying - the dialog applies configuration on save.

Socket layout stale after a pack update - drop a new instance; saved workflows keep the schema their node was born with. The README says this outright and it saves a lot of confusion for anyone who updates mid-project.

CategoryVantage/Utils

Inputs (3)

NameTypeDefaultDescription
valueSTRING—
conditionsSTRING[{"operator":"=","value":"","input":0}]—
input_0opt*—

Outputs (1)

NameTypeDescription
value*—