Nodes/TT_TextTools/TT_TextFileSelectorNode
ComfyUI Node

TT_TextFileSelectorNode

Random line from a text file, no text box required

By zzubnik·Created about a year ago·Updated about a year ago· 1
TT_TextFileSelectorNode
    • STRING
    seed42
    file_path/tmp/ComfyUI/custom_nodes/TT_TextTools/DefaultList.txt

    Somewhere between a big list of prompt options and a clean workflow graph, you have to pick a side. TT_TextFileSelectorNode picks the file: it reads a plain .txt file and returns one random non-empty line from it, per run, seeded so you can reproduce a roll. The README positions it as the drop-in alternative to a text box - instead of pasting forty lines into a TT_TextInput, you keep them in a file and point this node at it. If your prompt variation lists live in notes, spreadsheets, or files a chatbot wrote for you, this keeps them out of the graph entirely.

    How it works. Each run it re-opens the file at file_path, reads every non-empty line, strips whitespace, and picks one with random.choice after seeding with seed. Two details matter here. First, the file is reloaded on every run - edit the .txt and the very next generation sees it, no restart, no re-import. Second, if the path doesn't exist or the file is empty, the node doesn't error; it quietly outputs the string "No options available".

    The inputs that matter:

    • file_path - the path to your text file. The default is computed from wherever the pack is installed, pointing at the DefaultList.txt that ships with it (roughly 1,100 hand-written scene and travel lines like "A misty Irish cliff, emerald waves crashing against jagged stone edges").
    • seed - defaults to 42; same seed + same file = same line out. Change it to roll again.

    The output is a STRING, which you can feed straight into a TT_StoryCombiner box, a CLIP Text Encode, or any string input that accepts a connection. It's the file-based sibling to TT_TextInput - same output type, so the two swap freely on the same wire.

    Where people get burned. The most common trap is the path. ComfyUI saves the file_path value into the workflow JSON, and that value is an absolute path. Build the workflow on one machine and load it on another - or move the pack - and the saved path may point at a file that doesn't exist there, so you get "No options available" instead of a line. Fix: point file_path at a file you control (e.g. C:\Users\you\lists\settings.txt or /home/you/lists/settings.txt), or re-set it after loading the workflow. Second gotcha: it treats every line as an option, so no multi-line entries - if a "line" of your list needs to contain several prompt fragments, it won't. And it reseeds Python's module-global random on each call, same as its sibling nodes, which is a nothing-burger unless you're running other Python-random-based nodes in the same session.

    Install. ComfyUI Manager → search "TT_TextTools" → install, restart; or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zzubnik/TT_TextTools
    

    restart ComfyUI. No dependencies, no model files - the pack's entire footprint is a handful of Python files. The bundled DefaultList.txt is there to make the node work the moment it's installed, but you'll almost certainly point it at your own list.

    CategoryTT_TextTools

    Inputs (2)

    NameTypeDefaultDescription
    seedINT42
    file_pathSTRING/tmp/ComfyUI/custom_nodes/TT_TextTools/DefaultList.txt

    Outputs (1)

    NameTypeDescription
    STRINGSTRING