Nodes/isekai-comfy-node/Random Line From File
ComfyUI Node

Random Line From File

A seeded wildcard picker for your prompts

By isekai-sh·Created 9 months ago·Updated 8 months ago· 3
Random Line From File
    • random_line
    file_nameString
    seed0

    IsekaiRandomLineFromFile is a text-file wildcard node in disguise. You point it at a file full of prompt fragments - one per line - and it hands back one random line as a STRING you can splice into a prompt. The reason to pick this one over the many wildcard systems out there is the seed: the same seed always returns the same line from the same file. That makes it deterministic in a way most wildcard implementations aren't, which is genuinely useful when you're hunting a specific result and want to reproduce it.

    How it works. You give it a file_name and it resolves the file through ComfyUI's folder_paths - the same mechanism the rest of ComfyUI uses to find models and text files. It appends .txt for you if you forget it, so "outfits" loads outfits.txt. It reads the file (UTF-8 first, falling back to your system encoding), strips each line, drops empty ones, seeds Python's random with your seed, and picks a line. Same file + same seed = same line, every run. Change the seed, get a different line. That's the whole mechanism, and it's a good one: no hidden state, no cross-run memory, just a seeded RNG.

    The one thing that trips people: the file has to be where ComfyUI looks for text files - the text_files folder ComfyUI resolves via folder_paths (on a typical install that's ComfyUI/text_files, the same place other load-text nodes read from). If the file isn't there, the node prints [Isekai] Random From File: File not found to the console and returns an empty string. It won't crash - it'll just silently give you nothing, which is its own kind of confusing.

    Inputs that matter. Two, both required:

    • file_name - filename without the .txt, default "String". "String" is a leftover default, not a magic file - replace it or you'll get nothing.
    • seed - 0 to 2^64. Fix it to pin your selection; change it to roll again.

    Output is a single random_line (STRING). The natural wiring is into a text-concat node or straight into a CLIP text encode next to your static prompt - think "quality, (fragment from file), rest of prompt." It plays the same role as the {this|that} batch wildcard trick that's been around since A1111 days, just file-backed and seed-driven instead of inline.

    Install. Standard pack install: ComfyUI Manager → search "isekai" → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/isekai-sh/isekai-comfy-node
    cd isekai-comfy-node
    pip install -r requirements.txt
    

    Restart, then drop your text files in the right text_files folder. No model downloads, nothing heavy in requirements.txt.

    Common issues. Most failures here are file location or encoding: file not in text_files, or saved as something other than UTF-8 (the node tries a fallback encoding, but if your file is UTF-16 or Windows-1252 with odd characters, lines can come back garbled - save as UTF-8 and move on). Empty file or all-empty lines means no valid lines and an empty return. And a design note: selection is per-execution, not per-batch - if you want each image in a batch to get a different line, drive the seed from something that changes per item, or you'll generate the whole batch from one line.

    CategoryIsekai/IO

    Inputs (2)

    NameTypeDefaultDescription
    file_nameSTRINGString
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    random_lineSTRING