Nodes/Quality of Life Nodes for ComfyUI/Load Random Line From Text File (Soze)
ComfyUI Node

Load Random Line From Text File (Soze)

A one-file wildcard picker

By SozeInc·Created 2 years ago·Updated 5 days ago· 10
Load Random Line From Text File (Soze)
    • text_output
    filename_path
    prepend_text_line
    append_text_line

    This one does exactly what it says: point it at a text file, one option per line, and every time it runs it grabs a random line and hands it back as a string. It's the simplest possible version of the "wildcard" idea you'll see in bigger packs - a file of two hundred character names, a file of art styles, a file of camera angles, and this node picks one so you're not manually swapping text between runs.

    How it works

    There's no nested syntax here, no weighting, no __file__ references inside other files - just one file in, one random line out. If you've used Impact Pack's wildcard system or A1111-style dynamic prompts, think of this as the stripped-down single-purpose cousin: it trades flexibility for being trivial to reason about.

    The inputs and output that matter

    • filename_path - the path to your text file. Use an absolute path; a relative one depends on ComfyUI's working directory, which is a common trip-up across every path-taking node in this pack.
    • prepend_text_line / append_text_line - multiline strings glued before and after the picked line. This is the useful part: instead of a bare word, you can wrap it in scaffolding, e.g. prepend "a photo of " and append ", 4k, detailed" so the random pick drops straight into a full prompt fragment.

    The single output is text_output - the assembled string. Wire it into a CLIPTextEncode, or into this pack's own string-concatenation or find-and-replace nodes if you're building a bigger prompt out of pieces.

    Installing it

    ComfyUI Manager: search ComfyUI_Soze. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/SozeInc/ComfyUI_Soze.git, pip install -r ComfyUI_Soze/requirements.txt, restart. Nothing to download beyond that - it's a text-file reader, no models, no API keys.

    Common issues

    The file has to exist at exactly the path you gave it - this node has no fallback, so a typo just fails rather than silently doing nothing. If your list of lines includes blank lines (a common side effect of how some editors save files), you'll occasionally pick an empty line and get a suspiciously blank or truncated prompt out the other end; open the file and strip stray blank lines if you notice gaps in your results.

    One general habit worth having with any "pick something random" node: ComfyUI caches a node's output when none of its inputs changed since the last run. If you queue twice in a row and get the exact same line both times, that's usually the cache doing its job rather than the picker being broken - nudge another input, or just trust that it re-rolls on the next genuinely new queue.

    Categorysoze

    Inputs (3)

    NameTypeDefaultDescription
    filename_pathSTRING
    prepend_text_lineSTRING
    append_text_lineSTRING

    Outputs (1)

    NameTypeDescription
    text_outputSTRING