rsplit (from LIST)
Rsplit (from LIST) — split from the right, keeping the parts as one variable
- LIST
This is the rsplit that keeps all the pieces together. Where rsplit (from data list) hands each part to ComfyUI as an individual value, this variant returns a single Python LIST variable holding every part - which you then operate on as one unit. Same split-from-the-right logic, different container, different downstream workflow.
Choose this when you want to keep the parts bundled: split a string, then sort, join, count, or index into the parts as a whole rather than having ComfyUI process each part separately. The classic case is maxsplit=1 on a path or filename - rsplit(".", 1) gives you ["stem", "ext"] as a two-element list, and you grab whichever slot you need without the string falling apart into a batch.
How it works
Python's str.rsplit(sep, maxsplit), splitting from the right. Empty sep (the default) means whitespace splitting - any run of whitespace is a separator, and consecutive whitespace collapses so you don't get empty tokens. maxsplit defaults to -1 (no cap); set it to split only the last few separators.
"a,b,c".rsplit(",", 1)→["a,b", "c"]"folder/photo.png".rsplit("/", 1)→["folder", "photo.png"]" a b ".rsplit()(empty sep) →["a", "b"]
Inputs and outputs
string- required, the text to split.sep- optionalSTRING, default"". Empty means whitespace splitting; otherwise split on that literal separator.maxsplit- optionalINT, default-1. Max number of splits from the right.
Output is one LIST - a single Python list variable containing the parts.
Installing it
Part of the Basic data handling pack by StableLlama. ComfyUI Manager, search "Basic data handling", install, restart. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Pure Python, zero dependencies, no downloads. Under Basic/STRING in the menu.
Common issues
The biggest confusion is choosing between the two rsplit outputs, so let's be blunt about the difference: a data list is ComfyUI-native and each item flows through your graph individually; a LIST is one Python object that moves as a whole. The pack's README has a table on exactly this - data list for batch/per-item processing, LIST when you want index-based access or to work with the collection as a unit. If you connect a LIST output somewhere expecting per-item data, you'll get the whole list where one item was expected. Also remember maxsplit counts from the right, so with maxsplit=1 the unstripped remainder is the first element - ["everything else", "tail"] - which catches people used to split's left-handed order.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| string | STRING | — | |
| sepopt | STRING | — | |
| maxsplitopt | INT | -1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LIST | LIST | — |