load STRING from file
Read a prompt or config from a text file mid-workflow
- text
- exists
Basic data handling: PathLoadStringFile ("load STRING from file") reads a UTF-8 text file from disk and hands you its contents as a plain string - no parsing, no processing, raw bytes-to-text. Path in, text out, plus an exists flag. It's the node that lets the outside world feed data into your workflow instead of you typing it into widgets.
The killer use case is prompt or config files you manage outside ComfyUI. Keep your long, frequently-edited prompt in a .txt file, edit it in any editor, and load it with this node - your workflow picks up the change on re-run (it re-checks the file's modification time, so no stale cache). Same trick for batch parameters, filenames, negative prompts, or any setting you'd rather version-control as text than bury in a node. Pair it with this pack's string nodes and the read text becomes whatever you need it to be - split into lines, concatenated, matched, whatever.
How it works
A straightforward open(path, "r", encoding="utf-8") read. The details:
- UTF-8 only. A file in Latin-1 or UTF-16 will fail to decode and you'll get
exists=Falseand an empty string - no crash, just nothing. Save your text files as UTF-8. - Missing or unreadable → empty string +
exists=False. Same graceful degradation as the pack's image loaders. Wire the flag into a branch if a silent empty result would be bad. IS_CHANGEDis the file's mtime. Overwrite the file, re-run, get the new content. This is what makes "edit outside, run inside" actually pleasant instead of a cache fight.
Inputs and outputs
- path (STRING, default
"") - the text file to read. Absolute paths are safest. - text (STRING) - the file's full contents, no trailing-newline trimming, nothing else.
- exists (BOOLEAN) -
Trueif the read succeeded,Falseotherwise.
Installing it
Part of Basic data handling, the zero-dependency pack. ComfyUI Manager → search "Basic data handling" → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart after. No models, no pip.
Gotchas
The UTF-8 strictness is the one that bites - paste a prompt copied from a Windows Notepad file saved in ANSI and you'll get a mysteriously empty text with exists=False even though the file is clearly there. Convert the file to UTF-8 and move on. And since the node returns the entire file as one string, multiline content comes back with \n embedded - if you expected separate lines, run it through the pack's string-split node. Beyond that it's exactly what it says: the read half of "let me edit this workflow's inputs as a file." If you keep prompts in files anyway, this is the node that closes the loop.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| exists | BOOLEAN | — |