Starts with
Routing workflows by model family, one prefix at a time
- result
File names encode intent. flux1-dev and flux1-schnell share a prefix that says "I'm a Flux model, do Flux things." sd3_medium says the opposite. If your workflow can look at the front of a string and recognize the family, it can auto-configure itself - different schedulers, different CLIP setups, different CFG defaults - without you touching a slider.
That's the job of Starts with, from ComfyUI-BooleanExpression, Marco Zanella's zero-dependency logic pack. It returns true when the first string begins with the second, false otherwise. The mechanism is one Python call, haystack.startswith(needle), plus an optional case fold.
How it works
Three required inputs:
- haystack - "The string." The text you're inspecting.
- needle - "The string to search." The prefix you're matching.
- case_insensitive - defaults to True.
The default is worth internalizing: "FLUX1-dev" startswith "flux" is true, because both sides get lowercased first. Model filenames are all over the place on case, so leaving this on is almost always right. Turn it off for genuinely case-sensitive prefixes like version markers.
The output is a single result boolean. It feeds the pack's Conditional Branch, the And/Or/Xor/Not nodes, or any BOOLEAN input - same as every node in this pack.
The model-family router
This is the pattern that makes the node worth having. ComfyUI is a graph, not a program, so there's no built-in "if this model, use these settings." People build that themselves, and prefix matching is the cheapest reliable way to do it:
- filename starts with
flux→ pick the Flux-compatible checkpoint and its scheduler. - starts with
illustrious→ a different CLIP setup, because that family wants its own text encoder treatment. - starts with
realvis→ the photoreal-oriented default path.
The pack's own README even demonstrates conditional branching on aspect ratio to auto-pick prompts - same idea, applied to dimensions instead of prefixes. If you're wiring a workflow you share publicly, a few StartsWith gates make it "load any model, get sane defaults," which is a genuinely nice thing to hand someone. It's also a small enough node that even if you only use it once, it costs you nothing to keep installed.
Install
ComfyUI Manager is the easy route: search ComfyUI-BooleanExpression, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/marco-zanella/ComfyUI-BooleanExpression.git
Restart ComfyUI and look under Boolean Expressions → String Comparisons. No pip dependencies (the pack's requirements.txt is empty), no model downloads, pure stdlib Python. It's registered on the Comfy Registry, so Manager resolves it by title the first time.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| haystack | STRING | The string. | |
| needle | STRING | The string to search. | |
| case_insensitive | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | BOOLEAN | — |