Nodes/ComfyUI-TinyBee/Load String from File
ComfyUI Node

Load String from File

Read a text file into your workflow — prompts, captions, configs, anything

By TinyBeeman·Created about a year ago·Updated 10 days ago· 1
Load String from File
    • string
    filepath

    Sooner or later you'll want your prompt, your caption, or your config to live on disk instead of inside the workflow JSON. Maybe you're iterating on a prompt in your editor and want ComfyUI to just pick up the file. Maybe you have a hundred captions from a training run and need to load them one at a time. Load String from File is the dead-simple version of that: you give it a file path, it reads the whole file as UTF-8 text, and hands you the contents as a single STRING.

    That's the entire job, and the implementation is deliberately unglamorous - open(filepath, "r", encoding="utf-8") and f.read(). The two details that make it reliable rather than merely simple: an empty path or a missing file returns an empty string instead of throwing, and the node forces itself to rerun every execution. The second one matters more than it looks.

    The always-rerun behavior, and why it's the feature

    Most ComfyUI nodes skip re-running when their inputs haven't changed - that's the whole caching model. A file loader can't do that: the file can change on disk without the filepath input changing, so the node opts out of caching by returning float("NaN") from IS_CHANGED, the standard idiom for "always run me." The practical upshot: you can edit a prompt file, hit Queue, and the new text flows through - no node bypassing, no workflow reload, no "why is it still showing the old prompt" moment. The flip side is that anything downstream of this node also reruns every time, so it's not a node to hang a heavy sampler off if you want caching. For text it's a non-issue.

    The input and output

    • filepath - a STRING with a plain text box (not force-input, so you can type a path directly). Use an absolute path or one relative to where ComfyUI runs. An empty or missing path yields "", no error - which is friendlier than a crash but also easy to miss, so double-check the path if you're getting empty output.
    • string - the full file contents as one STRING.

    Pair it with Json Array To List (same pack) when the file contains a JSON array and you want a real list out of it, or feed it into a text encoder for a prompt you keep versioned in git.

    Install and gotchas

    It's part of ComfyUI-TinyBee, one install for the whole pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    or ComfyUI Manager → "ComfyUI-TinyBee" → restart. No models, no dependencies beyond the pack's light requirements.txt - it's pure stdlib file I/O. Two gotchas worth internalizing: first, it reads the file every run, so don't point it at a multi-gigabyte log and wonder why queues stall; second, encoding is UTF-8, and a file saved as something else (Windows Notepad's old default, some Excel exports) can come through mangled. Save your files as UTF-8 and you'll never think about it again. It lives in 🐝TinyBee/Strings.

    Category🐝TinyBee/Strings

    Inputs (1)

    NameTypeDefaultDescription
    filepathSTRING

    Outputs (1)

    NameTypeDescription
    stringSTRING