Nodes/qwen3-vl-comfy-ui/Qwen3-VL Prompt Splitter
ComfyUI Node

Qwen3-VL Prompt Splitter

Pry individual captions out of a batch blob, one index at a time

By Granddyser·Created 10 months ago·Updated 9 months ago· 44
Qwen3-VL Prompt Splitter
    • prompt
    • filename
    • total_count
    • is_last
    batch_text
    index0
    clean_prefixtrue

    Here's the workflow tension this node exists to solve: Qwen3-VL Batch Run (Folder) returns one giant string with every caption glued together, but most of the time you want the captions individually - one per image, so you can save them to per-file caption files, feed one into a prompt encoder, or walk them in a loop. Qwen3-VL Prompt Splitter is the tool that does the prying: you hand it the batch output, give it an index, and it returns the caption for that one image, along with its filename and the total count.

    It's a pure text parser - no model, no VRAM, no GPU. It just understands the batch format this pack writes, which is:

    === img_001.png ===
    A woman standing on a cliff at sunset...
    

    The === filename === line is the contract. The splitter regex-matches that pattern, splits the blob into (filename, caption) pairs, and gives you the one at the index you asked for.

    The three inputs

    • batch_text (STRING, multiline) - paste the output of Batch Run here, or wire it straight in from the batch node.
    • index (INT) - which caption to extract, 0-indexed (the tooltip says "Which prompt to extract (0-indexed)"). This is where a loop controller plugs in: iterate index from 0 to total_count - 1.
    • clean_prefix (BOOLEAN, default true) - strips the Next Scene: prefix if present, so a cinematic continuation prompt becomes raw prompt text instead of "Next Scene: A dolly shot toward...". Leave it on unless you specifically want the prefix kept.

    The four outputs, and the loop pattern

    • prompt (STRING) - the extracted caption for the current index.
    • filename (STRING) - which source image it came from (img_001.png). Perfect for writing a matching .txt caption file next to each image.
    • total_count (INT) - how many captions are in the blob. Tells your loop how big the dataset is.
    • is_last (BOOLEAN) - true on the final caption, so the loop knows when to stop.

    Those four outputs mirror Qwen3-VL Folder Loader (Loop)'s outputs almost exactly - same filename / total_count / is_last trio - because they're playing the same role on the text side that the Folder Loader plays on the image side. If you used Batch Run for speed and now want the captions treated individually, the splitter is the bridge.

    How it behaves

    Two behaviors worth knowing before they surprise you. Out-of-range indexes are clamped, not errors - an index past the end just returns the last caption with is_last true, so an over-running loop degrades instead of crashing. And if the blob contains no === filename === markers at all, it returns the literal string "No prompts found" with an empty filename and is_last true. If you see that, you've wired in text that isn't batch output (or the batch ran empty).

    Where it fits

    The full pipeline: Folder of images → Batch RunPrompt Splitter → loop controller → each prompt saved next to its filename. Or, if you want everything in one flat list for batch image-generation nodes, the sibling Qwen3-VL Prompt List Builder does the same parsing but joins all captions into a single separated string instead of exposing them one at a time.

    Install once via ComfyUI Manager (search "qwen3-vl-comfy-ui") or cd ComfyUI/custom_nodes && git clone https://github.com/Granddyser/qwen3-vl-comfy-ui && pip install -r requirements.txt (Linux: --break-system-packages for qwen-vl-utils), restart, and find it under Qwen3-VL. It's a quiet utility node, but it's the exact piece that turns "I captioned a whole folder" into "I have a caption file per image."

    CategoryQwen3-VL

    Inputs (3)

    NameTypeDefaultDescription
    batch_textSTRING
    indexINT00–10000Which prompt to extract (0-indexed)
    clean_prefixBOOLEANtrueRemove 'Next Scene: ' prefix if present

    Outputs (4)

    NameTypeDescription
    promptSTRING
    filenameSTRING
    total_countINT
    is_lastBOOLEAN