find
Where does that substring actually live?
- INT
count tells you how many. in (contains) tells you whether. find tells you where - the character index of the first occurrence. If you've got a string you need to cut or slice at a known marker, this is the node that finds the spot.
What it does
find wraps Python's str.find(substring, start, end). It scans the input and returns the lowest index where the substring starts. The important part: if the substring isn't there at all, it returns -1 instead of erroring. Optional start and end bound the search; leave them at 0 and it searches the whole string.
The inputs that matter:
string- what you're searching (required).substring- what you're locating (required).start,end- optional bounds, default 0 (the node treats 0 as "to the end").
Output: an INT - a character position, or -1.
Why you'd reach for it
Slicing. Say a prompt is built as "subject, style, quality" and you want everything after the second comma - find gives you the index, then the pack's string slice or split nodes do the cutting. You can also use the -1 sentinel for logic: find != -1 means "it's in there", which is the same check as the in node but without a separate node in the graph.
It's a search primitive, so it composes with everything else in the string family. The pattern is: find the marker, check for -1, then slice.
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. Zero runtime dependencies - pure stdlib - so the install is painless and conflict-free.
Where people get burned
The -1 sentinel is the classic trap. It's a legitimate output, not an error - but if you feed -1 straight into a slice, you slice from the end of the string (Python's negative indexing) and get something silently wrong. Always branch on "is it -1?" before using the result. Also: it's case-sensitive, and it returns the first occurrence - for the last one, that's the pack's rfind node.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| substring | STRING | — | |
| startopt | INT | 0 | — |
| endopt | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| INT | INT | — |