Nodes/SDVN_Comfy_node/πŸ’½ Load Text
ComfyUI Node

πŸ’½ Load Text

Read prompts from a .txt file, one line at a time

By StableDiffusionVNΒ·Created 2 years agoΒ·Updated about a month agoΒ· 118
πŸ’½ Load Text
    • string
    β—„custom_pathβ–Ί
    β—„input_dirβ–Ύβ–Ί
    β—„modeβ–Ύβ–Ί
    β—„index-1β–Ί
    β—„auto_indexfalseβ–Ί
    β—„stringβ€”β–Ί

    Keep your prompts in a text file and let ComfyUI read them. That's the core of it. You've got a .txt with one prompt per line - a prompt list you're working through, a set of captions, a wordbank - and this node pulls text out of it so your workflow generates from the file instead of from whatever you last typed into a box. It's the kind of node that turns "generate one image" into "generate through my list of 200 ideas."

    The genuinely useful bit is auto_index, which advances through the file line by line on each run. Queue the prompt, hit run repeatedly (or set a batch), and it walks down your list automatically - prompt 1, prompt 2, prompt 3 - no manual editing between runs.

    How it works

    The README describes three loading sources in priority order: an external string wired into the node wins first, then a custom .txt path, then .txt files sitting in the input folder. So you can hardcode a path, or drop files in the input folder and pick them, or pipe text in from another node - and it resolves them in that order.

    The mode decides what it pulls from the text:

    • line - a single line, chosen by index. This is the prompt-list workhorse.
    • keyword - pulls by a keyword match rather than position.
    • fullfile - the entire file as one blob, for when the whole thing is your prompt.

    Output is a string list, so in line mode with a range or in fullfile mode you can hand multiple values downstream for batch iteration.

    The inputs that matter

    • mode - line, keyword, or fullfile, as above. Pick line for prompt-per-line files.
    • index - which line to grab in line mode. -1 (the default) typically means "last" or "all" depending on mode - set a real number to target a specific line.
    • auto_index - the auto-advance toggle. Turn it on and successive runs step through the file automatically, which is the whole reason to use this for a prompt list.
    • custom_path - a direct path to a .txt file if you're not using the input folder.
    • input_dir - the picker for .txt files found in the input folder.
    • string (optional) - an external string input, which takes top priority when connected.

    The output string (list) wires into your CLIP text encode or any text-consuming node.

    Common issues

    It keeps returning the same line. auto_index is off, so index stays put. Turn auto_index on to advance through the file across runs, or change index manually each run.

    My file isn't in the input_dir dropdown. Drop the .txt into ComfyUI's input folder and refresh, or skip the dropdown entirely and point custom_path at the file. Remember the path is server-side on a remote/hosted instance.

    Wrong text loaded. Mind the priority order: a connected string input overrides custom_path, which overrides the input-folder pick. If you wired something into string, that's what wins regardless of the other fields.

    Blank lines throw off my count. Empty lines still count as lines. Clean your file, or account for them when setting index.

    Installing SDVN_Comfy_node

    ComfyUI Manager: search "SDVN_Comfy_node" β†’ install β†’ restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node
    

    Then pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt from the ComfyUI root and restart. There's a matching Save Text node in the pack if you want to write results back out. The node is under πŸ“‚ SDVN / πŸ’‘ Creative.

    CategoryπŸ“‚ SDVN/πŸ’‘ Creative

    Inputs (6)

    NameTypeDefaultDescription
    custom_pathSTRINGβ€”
    input_dirCOMBO1 options: None
    modeCOMBO3 options: line, keyword, fullfile
    indexINT-1β€”
    auto_indexBOOLEANfalseβ€”
    stringoptSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    stringSTRINGβ€”