Not equal to
\"Not equal to\" in ComfyUI without writing a line of Python
- result
Don't let the "alphabetical" in the class name throw you - this node isn't about ordering anything. It's the simplest possible question in a workflow: are these two strings different? Feed it two text values, it hands you back a true/false, and that boolean is the lever that decides which way your graph goes next.
It's from ComfyUI-BooleanExpression, Marco Zanella's small logic pack. The pack is pure Python with zero dependencies and no models to download - the whole point is giving ComfyUI the if/then muscle it ships without. ComfyUI is a graph, not a programming language, so there's no built-in "if" statement; conditional behavior is something you build from boolean nodes like this one feeding a Conditional Branch. This is exactly the pattern people constantly ask about on r/comfyui - "I need to bypass this image if the user doesn't load one," "switch the prompt if the aspect ratio changes" - and a string inequality is usually the first condition in that chain.
How it works
Under the hood it's a one-liner: first != second, with an optional case-fold first. No API calls, no model inference, no GPU. That's the whole mechanism, which is honestly refreshing after a week of wrestling with node packs that drag in half of PyTorch just to resize an image.
The inputs, all required:
- first - the first string.
- second - the second string.
- case_insensitive - defaults to True.
That last one is the trap. By default this node treats "FLUX" and "flux" as equal, because it lowercases both sides before comparing. Most of the time that's what you want - you're comparing model names or prompt tags where case is noise. But if you're doing anything where "Beta" must not equal "beta" (version tags, IDs), flip case_insensitive off.
The output is a single result boolean. Wire it into the pack's Conditional Branch (condition input), or into And/Or/Xor/Not, or into any other node that accepts a BOOLEAN input. One useful variant: run this into a Not when you'd rather think in terms of "is equal" - the graph reads easier if the node name matches your intent.
Where you'd actually use it
- Route prompts by what model is loaded: branch on
model_tag != "flux". - Detect when a setting drifted from your expected default and re-apply something.
- Keep a reusable subgraph honest: assert the incoming text isn't the placeholder you left in.
The one gotcha that bites
This pack ships two nodes both labeled "Not equal to": this string one and an arithmetic one that compares numbers. Search "not equal to" in the node menu and you'll see both - pick by category (this one lives under Boolean Expressions/String Comparisons). Grab the arithmetic one for numbers, this one for text, and never wire a number into it expecting numeric logic.
Install
Easiest via ComfyUI Manager - search ComfyUI-BooleanExpression and install. Or, manually:
cd ComfyUI/custom_nodes
git clone https://github.com/marco-zanella/ComfyUI-BooleanExpression.git
Restart ComfyUI, then find it under Boolean Expressions → String Comparisons. That's it - no pip install needed, nothing to download, and the pack is on the Comfy Registry so Manager finds it on the first try. If the node shows up red in a downloaded workflow, it's almost always that you haven't restarted after installing.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| first | STRING | The first string. | |
| second | STRING | The second string. | |
| case_insensitive | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | BOOLEAN | — |