String EndsWith
Check the tail end of your text, for routing and validation
- bool
String EndsWith is the mirror of StartsWith: it checks whether a string ends with a given suffix and hands you back a boolean. It sounds trivial, but "does this end with X" is one of the most useful filters in workflow automation - especially when you're dealing with filenames, extensions, or any text where the tail carries meaning.
What it is
It runs Python's s.endswith(suffix) and returns the result as True or False. Exact suffix match, nothing fuzzy. If s ends with suffix, you get True; otherwise False.
The canonical use case is file extensions: "photo.png" ends with ".png", so a branch that says "if the filename ends with .png, save to the PNG folder" just works. You can route on output formats, on batch names, on anything where the ending is the discriminator. Like its sibling, the boolean output plugs straight into a switch, reroute, or conditional node to make the graph decide for itself.
The inputs and outputs
s(STRING) - the text being tested.suffix(STRING) - the substring you expect at the end.bool(BOOLEAN) -Trueifsends withsuffix.
Note the empty case, same as StartsWith: an empty suffix matches every string, so an unset suffix returns True.
How to install it
Part of the string-util pack - one tiny dependency-free repo:
cd ComfyUI/custom_nodes
git clone https://github.com/kale4eat/ComfyUI-string-util
or install "ComfyUI-string-util" via ComfyUI Manager and restart. It's under the string-util category.
Common issues
Case sensitivity is the one that bites: ".PNG" does not match "photo.png". Run both sides through String Upper or String Lower if your suffixes might arrive in mixed case. And remember this tests the ending only - checking a middle substring is String Find, checking the beginning is String StartsWith, and checking "is it exactly this string" is String Equal. All in the same pack, so you've got the full predicate set without installing anything else.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| s | STRING | — | |
| suffix | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |