endswith
A cheap way to check what a string is
- BOOLEAN
Want to know if a filename ends in .png or .safetensors without writing a regex? This is your node. endswith is the plainest of the string-inspection family, and for a lot of workflow logic it's the only test you actually need.
What it does
It's a direct wrapper over Python's str.endswith(suffix, start, end). Feed it a string and a suffix, and it returns True if the string ends with that suffix, False otherwise. The optional start and end let you check only a slice of the string; leave them alone and the whole string is checked.
The inputs that matter:
string- what you're testing (required).suffix- what it should end with (required).start,end- optional bounds, both defaulting to 0 (the node treats 0 as "to the end").
Output: a BOOLEAN.
Why you'd reach for it
It's a routing gate. Feed the boolean into the pack's if/else control-flow node and you can branch on file type: save differently for PNGs versus WebPs, only run an upscale path for .png, validate that a path points at the right kind of file before you do anything with it. It's also the more precise cousin of in (contains) - you don't care that the string somewhere has .png, you care that it ends there.
The realistic scenario is exactly what people ask about in r/comfyui: routing on file paths and extensions from the pack's path nodes. endswith is the missing piece that turns "I have a path" into "I have a path of the kind I can handle."
Installing
Part of Basic data handling by StableLlama. In ComfyUI Manager search "Basic data handling" → Install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart. The pack ships with zero runtime dependencies - pure stdlib - so it installs clean and can't collide with your other nodes.
Where people get burned
It's exact and case-sensitive. ".PNG" will not match ".png", which trips up people checking file extensions from inconsistent sources - run both sides through the pack's casefold node if you need leniency. And it's a suffix test, not a pattern test: endswith(".png") matches anything ending in those four characters, no wildcards. That's the whole feature.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| suffix | STRING | — | |
| startopt | INT | 0 | — |
| endopt | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BOOLEAN | BOOLEAN | — |