Nodes/Rathius_ComfyNodes/Load Text from File (Upload)
ComfyUI Node

Load Text from File (Upload)

Stop copy-pasting your prompts — load them from a .txt file instead

By Rathius-Saranoth·Created 10 months ago·Updated 9 months ago· 0
Load Text from File (Upload)
    • text
    file_nameexample.txt

    If you keep a long prompt block in a text editor and then re-paste it into every workflow, this node is for you. It takes a .txt file sitting in ComfyUI's input folder, reads the whole thing, and hands it to the graph as a single text string. Edit the file, queue again, and the new text flows through - no copy-paste, no risk of nuking a prompt you spent an hour tuning.

    It's one of two nodes in the tiny Rathius_ComfyNodes pack, written by a self-described Python beginner as a learning project. That pedigree is worth knowing: this is a small, dependency-free utility, not a heavyweight framework node. There's no requirements.txt and no model to download - just nodes.py plus a bit of frontend JavaScript. Low install risk, low expectations.

    How it works

    The interesting bit is the upload button. In the Python schema, the node only declares a single file_name string widget - but the pack ships a js/textUploadWidget.js extension that grabs that widget, hides it, and replaces it with a Choose .txt File button. When you click it, the file is POSTed to ComfyUI's /upload/image endpoint (yes, that one - it accepts any file type) into the input/text_prompts/ subfolder, and the returned path is stored back in the hidden widget. The Python side then resolves it with folder_paths.get_annotated_filepath() and returns the file contents as UTF-8 text.

    The node also implements IS_CHANGED by hashing the file, so ComfyUI re-runs anything downstream when the file's content actually changes. That's what makes the "edit the file, hit queue" loop work without you touching the graph.

    The inputs and outputs that matter

    There's really only one thing to set, and it's hidden behind the button:

    • file_name - a string widget you normally never touch; the upload button fills it in for you (default example.txt).

    The one output is text (STRING). Wire it into the positive or negative input of a CLIP Text Encode, or feed it into a text combiner like SimpleTextMixer from the same pack. You can use several of these nodes - one for positive, one for negative, one per segment - since the README's whole point is that you don't have to mess with the source material anymore.

    Installing it

    Via ComfyUI Manager: search Rathius_ComfyNodes and hit install, then restart. Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Rathius-Saranoth/Rathius_ComfyNodes
    # restart ComfyUI
    

    That's it - no dependencies to pip, no model files to fetch. It'll show up under RathiusNodes/Utils in the node menu.

    Where people get burned

    • The file path is baked into the workflow JSON. When you share a workflow that uses this node, whoever opens it needs the same .txt present in their input folder - usually ComfyUI/input/text_prompts/your_file.txt. Upload the button path alone won't travel.
    • It fails softly, not loudly. If the file can't be read, the node returns the literal string Error: ... instead of crashing. That string then flows straight into your prompt. If your output suddenly contains the word "Error", the file is missing or unreadable - check the input folder before blaming the sampler.
    • The upload button is a frontend convenience. If you're driving ComfyUI through its API or a queue script, the file has to already exist in input; nobody clicks a button for you.
    • Files are read at queue time via the content hash, so edits to the .txt take effect on the next queue - which is the feature, not a bug.

    It's a one-trick node, but it does the trick cleanly. If your prompts live in files, you'll wonder why you ever pasted.

    CategoryRathiusNodes/Utils

    Inputs (1)

    NameTypeDefaultDescription
    file_nameSTRINGexample.txt

    Outputs (1)

    NameTypeDescription
    textSTRING