Nodes/comfyui-promptsegmentselector/Prompt Segment Selector
ComfyUI Node

Prompt Segment Selector

The boring splitter that keeps multi-shot video workflows sane

By BarleyFarmer·Created 4 months ago·Updated 4 months ago· 2
Prompt Segment Selector
    • segment_1
    • segment_2
    • segment_3
    • segment_4
    • segment_5
    • segment_6
    • segment_7
    • segment_8
    • segment_9
    • segment_10
    • segment_11
    • segment_12
    text
    delimiter---

    The name is almost offensively literal, and that's the point. Prompt Segment Selector takes one multiline text box and splits it into up to 12 numbered string outputs based on a delimiter you choose. No model, no API key, no weights to download. It's pure text.split() with good hygiene wrapped in a node.

    So why does anyone bother? Because multi-shot video workflows are where ComfyUI graphs turn into spaghetti. When you're chaining shots on the Wan side of things - the Wan 2.2 FLF models, or the SVI (Stable Video Infinity) extension LoRAs that let you push past the 5-second clip - every segment of your story wants its own prompt, and each of those wants its own text node. That's a dozen little widgets you have to keep in sync, and the moment you reword shot one, you're scrolling through the graph trying to find which box holds shot seven. This node collapses the whole pile into one text box. You write all twelve prompts in a single widget, separated by ---, and each output feeds its own shot's prompt input.

    How it works

    Under the hood it's embarrassingly simple, which is exactly why it's reliable. The source does text.split(delimiter), strips leading/trailing whitespace off every segment, trims trailing empties, and pads the rest up to 12 slots with empty strings. If you feed it more than 12 segments it truncates to 12 and prints a warning to the ComfyUI console. That's the whole mechanism - one pass, no state, no list semantics to trip over. It's the kind of node you could write yourself in ten minutes and then immediately stop writing yourself in ten minutes.

    The inputs that matter

    There are only two, and a beginner only really sets one:

    • text (multiline STRING) - your combined prompt text. Each line between delimiters becomes one segment.
    • delimiter (STRING, default ---) - the string that separates segments. You'll probably leave it as-is.

    Outputs are segment_1 through segment_12, all plain STRING. Unused slots return "", which means the chain stays stable: any node downstream that expects a string still gets one. Anything that accepts a text prompt - CLIP Text Encode, the prompt input on the Wan/FLF and SVI workflow nodes - will take these directly.

    Why --- and not a blank line

    This is the one real gotcha, and it's why the default delimiter is what it is. ComfyUI normalizes whitespace inside multiline text widgets, so delimiters built out of blank lines (\n\n) can silently stop matching. A distinct token like --- survives that normalization. If you change it, pick something else that won't accidentally appear inside your prompts - a stray --- in a sentence is a surprise extra split, and there's no escaping.

    The other intentional quirk: empty middle segments are preserved, so a---\n\n---c yields segment_1="a", segment_2="", segment_3="c". That's not a bug - it keeps your shot indices aligned when you deliberately leave a slot blank. Only trailing empties get trimmed.

    Installing it

    The README is one command and zero dependencies (it only uses the Python stdlib, and pyproject.toml confirms nothing beyond Python ≥3.9):

    cd ComfyUI/custom_nodes
    git clone https://github.com/BarleyFarmer/ComfyUI-PromptSegmentSelector
    

    Restart ComfyUI and you'll find Prompt Segment Selector under text/utility. It's also on ComfyUI Manager if you'd rather search for "comfyui-promptsegmentselector" there. No model files, no pip installs, nothing to go stale.

    Where people trip

    The console warning for >12 segments is easy to miss - it goes to the terminal that's running ComfyUI, not the UI. If shots start coming out empty or shifted, that's the first place to look. The rest of the failure modes are all "I put my delimiter inside a prompt" or "I expected blank-line splitting to work," both covered above. It's a small tool that does one thing and does it predictably - the boring kind of node that saves you an afternoon in an eight-hour video session.

    Categorytext/utility

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    delimiterSTRING---

    Outputs (12)

    NameTypeDescription
    segment_1STRING
    segment_2STRING
    segment_3STRING
    segment_4STRING
    segment_5STRING
    segment_6STRING
    segment_7STRING
    segment_8STRING
    segment_9STRING
    segment_10STRING
    segment_11STRING
    segment_12STRING