Nodes/comfyui-axces2000/✂️ String Extractor
ComfyUI Node

✂️ String Extractor

Run one prompt per line and batch the whole queue

By axces2000·Created 6 months ago·Updated about a month ago· 12
✂️ String Extractor
    • text_out
    • index_out
    text
    index0
    modeKeep

    If you've ever wanted to run 20 variations of a prompt and hand-pick the winners, ✂️ String Extractor is the node that does the drudgery. Paste a list into it - one prompt per line, no formatting required - set the mode to Increment, and queue your batch. Each run automatically pulls the next line out and feeds it to your pipeline. It's the batch-prompt workhorse this pack is quietly built around, and it pairs perfectly with its sibling 🔗 String Combine for assembling multi-part prompts line by line.

    How it works

    The Python side is deliberately stateless. It splits your text into lines, ignoring blank ones, and extracts by index - line 1 is index 1, not 0. The index advancement actually happens in the node's JavaScript: a beforeQueued hook fires before each prompt gets queued, so with a multi-run queue each item serializes with the next line's index baked in. That's the clever bit, and it's why it works across scheduled batch runs instead of giving you the same line five times.

    The rules are simple and worth internalizing:

    | index value | what happens | |---|---| | 0 | full textarea passed to output, unchanged | | 1 to N (valid line) | that line is extracted; a trailing space is added if it's missing | | greater than line count | full textarea passed unchanged, index resets to 0 |

    That trailing space isn't a bug - it's so the extracted line joins cleanly into a String Combine without gluing onto the next word.

    Inputs and outputs

    • text - a STRING, multiline. Type or paste your list, or wire it in from another text node.
    • index - the INT line to extract. 0 is passthrough, 1 is the first non-empty line.
    • mode - Keep (index stays put, use for a manual "always line 3" workflow), Increment (advance one per run, wrapping from the last line back to 1), or Randomise (jump to a random valid line each run).
    • text_out - the extracted line, or the full block for index 0 / out of range. Wire it into CLIP Text Encode or a combiner.
    • index_out - the index after the mode was applied. Feed it to a Display Int node to watch your batch progress.

    One detail worth knowing: Randomise forces a re-run via IS_CHANGED returning a non-deterministic value, so you won't get stuck with a cached output - each execution genuinely rolls the dice again.

    Where people get burned

    • Blank lines are skipped, but they still shift nothing - line counting is over non-empty lines only. If your list has empty lines and your indexes look "off," that's why.
    • Out of range means passthrough, not an error. If you set index 25 on a 5-line list you get the whole block dumped out and the index snaps back to 0. If that happens, your list is shorter than you think.
    • The mode selector is disabled at index 0 or out of range, which is the node telling you it's in passthrough mode. Set a real index first.

    Installing it

    Same as the whole pack: ComfyUI Manager, search axces2000, install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/axces2000/comfyui-axces2000.git
    pip install -r comfyui-axces2000/requirements.txt
    

    Then restart ComfyUI. This node itself is pure Python - no model files, no downloads, nothing heavy. The pack's requirements.txt (torchaudio, soundfile) only matters for the audio nodes. It's a small MIT-licensed utility pack without much community footprint, but for a list-of-prompts tool that's fine: it does one thing, and it does it without ever making you think about it mid-batch.

    Categorytext

    Inputs (3)

    NameTypeDefaultDescription
    textSTRING
    indexINT00–9999
    modeCOMBOKeep3 options: Keep, Increment, Randomise

    Outputs (2)

    NameTypeDescription
    text_outSTRING
    index_outINT