π Read Text File
The Simplest Way to Load Prompts, Wildcards, and Notes
- STRING
ComfyUI keeps your prompts in widgets and your images in metadata, but a lot of real-world workflow data lives in plain text files - wildcard lists, LoRA trigger words, saved prompt logs, batch manifests. ReadTextFile (π Read Text File, from ControlFlowUtils) is the read half of the pack's file pair: point it at a path, get the contents back as a string, and feed that string anywhere your workflow accepts text.
It's about as simple as a node gets, which is exactly why it's useful. It's the missing "load from disk" primitive that ComfyUI doesn't ship by default.
The inputs and output
- file (required) - the path, absolute or relative (default
file.txt). Relative resolves against ComfyUI's working directory, so absolute paths are the safer habit. - line - which line to read.
0(default) reads the whole file. Any positive number returns just that line (1-based). This is the whole "wildcard picker" trick: set line to a dynamic value and you can pull one entry out of a list file at a time. - on_eof - what happens when you ask for a line beyond the end of the file. Default (true) means Ignore: return an empty string silently. Turn it off and the node raises an error instead. Leave it on unless a missing line should genuinely stop your workflow.
The single output, STRING, is the file contents (or the requested line). Wire it into a CLIP Text Encode's text input, a Save Text File, a filename builder - anywhere text flows.
Where people use it
The two canonical jobs:
- Wildcards. Keep a
prompts.txtwith one prompt variant per line, setlineto a dynamic index, and you've got a poor man's wildcard system without any extra pack. Drive the line number from a loop counter or a random INT and every generation pulls a different prompt. - Logs and notes. Read back a file that a previous workflow pass wrote with Save Text File - a saved seed, a trigger-word list, a settings manifest - and have the current run respond to it. That's the two-file pair working as a simple persistence layer between runs.
The on_eof gotcha deserves a second mention: with line-mode on and on_eof set to ignore (the default), a too-large line number silently gives you an empty string. If your wildcard list suddenly starts producing blank prompts, that's usually the cause - the file just doesn't have that many lines. Handle it by cycling the line index back to 1, or by letting on_eof raise so you notice.
Also note the UTF-8: the node reads UTF-8 plaintext. A file saved as something else (e.g. Windows-1252 from some other tool) can come back with mojibake. Re-save as UTF-8 and it's clean.
Install
ReadTextFile ships in VykosX/ControlFlowUtils:
# ComfyUI Manager β Install Custom Nodes β search "ControlFlowUtils"
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/VykosX/ControlFlowUtils
Restart, find it under πΊ VykosX-ControlFlowUtils, right next to Save Text File. No dependencies, no models - it just reads bytes and hands you a string.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| file | STRING | file.txt | Absolute or relative path of the file to read |
| lineopt | INT | 0 | Line number to read within the file or '0' to read the whole file at once |
| on_eofopt | BOOLEAN | true | Action to perform if the specified line number does not exist |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | Full contents of the text file or the line of your choice |