String Split
Break a string into a list on a separator
- strings
String Split is the reverse of String Join: it takes one string, splits it on a separator, and outputs a list of strings. It's the node that turns a CSV-ish line or a comma-separated prompt into separate pieces you can process, filter, or recombine. One warning up front: the separator defaults to empty, and an empty separator crashes this node. Give it a real separator and it's a workhorse.
What it is
It runs Python's s.split(sep) and returns the pieces as a list output. Split "a,b,c" with sep = "," and you get ["a", "b", "c"]. The output is genuinely a list (OUTPUT_IS_LIST in the source), so it feeds anything that consumes a batch or list of strings - including this pack's String Join, which is its natural partner.
The workflow pattern is powerful: split a prompt or a data line into parts, inspect or filter individual elements (using predicates like String StartsWith or String Equal per element), then Join the survivors back together with the separator of your choice. You've just made a text-processing pipeline with nothing but this pack.
The inputs and outputs
s(STRING) - the text to split.sep(STRING) - the separator to split on. Required in practice - leaving it empty raises aValueErrorand fails the node, because Python'sstr.split("")is illegal. Unlike a bare.split()call, this node always passes the separator through, so there's no whitespace-splitting default.strings(STRING, list) - the resulting list of pieces.
How to install it
Part of the string-util pack, a 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
The empty-separator crash is the number one gotcha - a beginner who leaves sep at its default and clicks run gets a red node with a ValueError: empty separator. Type a separator (, ; | whatever your data uses) and it's solved. Second: if your data has leading/trailing spaces, you'll get empty strings in the list ("a, b" on "," gives ["a", " b"] with that space intact) - run the string through String Strip first, or account for the spaces. Third: this is literal splitting, not regex - no wildcards, no "one or more spaces" logic.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| s | STRING | — | |
| sep | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| strings | STRING | — |