πͺ String Tokenizer
Turn one comma list into a switchable prompt, live
- token
Here's a cheap trick that makes animations dramatically less boring: put a comma-separated list of prompt fragments in a string, then swap which one is active frame by frame. String Tokenizer [Dream] is the node that does the swapping. Give it "sunset, storm, dawn", feed selected from a frame counter or the pack's Laboratory node, and you get one of those words out - a rotating prompt that changes over time without touching a single widget mid-run.
The mechanism is exactly as simple as it should be. The node splits text on separator (default ,), then returns parts[selected % len(parts)] with whitespace stripped. The modulo is the clever bit: it means you can drive selected with an ever-increasing number - like the frame counter itself - and it wraps around the list forever instead of erroring. That's the whole thing, and it's why the node is marked as an output node: its only real job is producing that one string for the rest of the graph.
The inputs that matter
- text - your token list, multiline-capable, separated by
separator. - separator - the delimiter (default
,). If you leave it empty, it falls back to splitting on spaces. - selected - the index to pick, starting at 0. Negative or huge values are fine thanks to the modulo; drive it with a frame counter or Laboratory output for automatic rotation.
Output is a single token (STRING). The classic wiring is: token β Build Prompt [Dream] (or any text concat) β your CLIP text encode, with the counter ticking selected up each frame.
Installing it
Part of Dream Project Animation Nodes - install the pack via ComfyUI Manager (search "Dream Project Animation Nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-project.git
cd comfyui-dream-project
pip install -r requirements.txt
Restart ComfyUI. The numpy<2.0 pin in requirements is the one install quirk.
Common issues
People get burned in two spots. First: if your separator appears inside a token (like "red, greenish-blue"), you'll get mid-phrase chunks - either change the separator or keep the list flat. Second: selected has no upper bound on the widget, but the modulo means out-of-range values silently wrap, so an index of 5 on a 3-item list gives you item 2, which can look like a bug until you notice. And the pack-wide caveat: the README declares the pack unmaintained - irrelevant for a split-and-pick utility that runs fine on current ComfyUI.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | β | |
| separator | STRING | , | β |
| selected | INT | 0 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| token | STRING | β |