Nodes/Comfy Text Stats/Text -> Load Text File
ComfyUI Node

Text -> Load Text File

Load a .txt file into your ComfyUI graph — comments and all

By scofano·Created 11 months ago·Updated 3 months ago· 3
Text -> Load Text File
    • text
    • dictionary
    file_path
    dictionary_name[filename]

    Tired of copy-pasting a caption file or prompt list into a text widget every time you change one line? That's the niche this node fills. Point it at a UTF-8 text file and it hands the contents to your workflow as a plain string, plus a dictionary of the lines for anything that wants a proper list. It's one of the eight utilities in the Comfy Text Stats pack (scofano/comfy-text-stats), a small MIT-licensed set that's pure Python - no models, no GPU, no dependencies to argue with.

    What it actually does

    The node reads the file, drops any line whose trimmed content starts with #, strips the \n/\r off each remaining line, and rejoins them with newlines. That comment filtering is the feature people underrate. Keep a caption list, a set of LoRA trigger words, or a small config file with # notes at the top, and only the real content flows into your graph. The code explicitly mirrors the behavior of WAS Node Suite's text loader, so if you're migrating from that, you're not relearning anything.

    The inputs and outputs that matter

    There are only two inputs, and both are plain strings:

    • file_path - an absolute path you type in or wire in. There's no file-browser widget, which is the one thing that'll trip you up the first time.
    • dictionary_name - the key for the dictionary output. The default is [filename], which expands to the file's name without its extension; type anything else for a custom key.

    Outputs: text is the joined file content as a normal STRING - wire it anywhere a text node goes, into an LLM, a caption combiner, or a prompt assembly. dictionary is a DICT mapping that key to the filtered line list, which is the handy one when a downstream node wants to iterate line-by-line instead of you re-splitting the string yourself.

    Installing it

    The node ships in the Comfy Text Stats pack, so you get all eight utilities in one install. Easiest route is ComfyUI Manager:

    1. Open Manager → Custom Nodes Manager.
    2. Search for "Comfy Text Stats".
    3. Install, then restart ComfyUI (or use "reload custom nodes").

    Prefer the terminal? Same result:

    cd ComfyUI/custom_nodes
    git clone https://github.com/scofano/comfy-text-stats
    

    Then restart ComfyUI. That's the entire install - the pack's requirements file literally contains only a comment saying there are no external dependencies, and there are no model files to download. On a ComfyUI install that's already flirting with dependency hell, a pure-stdlib pack like this is a small relief.

    Where people get burned

    The missing-file case is quiet. If the path doesn't exist, you get an empty text and {key: []}, and the node prints a warning to the ComfyUI console. If something downstream suddenly has nothing to work with, check that console message first - it's usually a typo in the path, not the node misbehaving.

    Worth knowing: this node is a pure function, and it re-reads the file on every graph execution. Its change detection uses the file's modification time and size, so edit the file on disk, hit run, and the new content flows through automatically. For a text utility in a node graph, that's exactly the behavior you want.

    CategoryText/Utils

    Inputs (2)

    NameTypeDefaultDescription
    file_pathSTRING
    dictionary_nameSTRING[filename]

    Outputs (2)

    NameTypeDescription
    textSTRING
    dictionaryDICT