String Comparison
The one string node to rule them all
- result
If you only install one string-comparison node from this pack, make it this one. String Comparison is the whole string department collapsed into a single node: twelve different tests behind one dropdown, from plain equality to contains to alphabetical ordering. Instead of hunting for "Starts with," "Not equal to," and "Ends with" as separate nodes, you get one box and a menu.
It's the flagship of the string section in ComfyUI-BooleanExpression, Marco Zanella's dependency-free logic pack. Under the hood it's a Python match statement over the chosen operand - same math as the pack's dedicated nodes, bundled into one canvas-saving widget.
How it works
The inputs:
- first - "The first string."
- second - "The second string."
- operand - the comparison, picked from a dropdown with 12 choices:
- Ordering:
<,≤,=,≠,≥,> - Substring:
contains,does not contain - Prefix/suffix:
starts with,does not start with,ends with,does not end with
- Ordering:
- case_insensitive - defaults to True.
The default operand is <, and here's the trap: these are alphabetical comparisons, not numeric ones. "10" < "9" is true, because "1" sorts before "9". If you're comparing numbers, use the pack's arithmetic comparison nodes - that's what they're for - and leave this one for text. Lexicographic order is also how you'd sort prompts alphabetically, which is a real but niche use.
With case folding on (the default), first and second are both lowercased before every test, so "FLUX" equals "flux" and "Photo.png" endswith ".png". Output is a single result boolean, wired into the pack's Conditional Branch, the And/Or/Xor/Not group, or any BOOLEAN input.
Why you'd use this over the dedicated nodes
Two honest reasons. First, canvas space - ComfyUI graphs turn into spaghetti fast, and the community's most common complaint about node packs is that they make a graph harder to read. One node with a dropdown replaces up to six others. Second, experimentation - you can change the comparison from "starts with" to "contains" by clicking a menu instead of deleting and re-adding a node. When you're prototyping a conditional workflow, that's the difference between a good loop and a frustrating one.
The cost is discoverability: ≠ and ≤ in a dropdown are less obvious than a node literally named "Does not end with." If you're sharing a workflow with beginners, the dedicated nodes read friendlier. If you're building for yourself, this is the one to keep.
Install
ComfyUI Manager: search ComfyUI-BooleanExpression, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/marco-zanella/ComfyUI-BooleanExpression.git
Restart ComfyUI; it's under Boolean Expressions → String Comparisons. The pack is pure Python with an empty requirements.txt - no pip step, no model downloads - and it's on the Comfy Registry so Manager finds it by title. Red node in a shared workflow almost always means you skipped the restart.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| first | STRING | The first string. | |
| second | STRING | The second string. | |
| operand | COMBO | < | The string comparison. |
| case_insensitive | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | BOOLEAN | — |