Nodes/Duanyll Nodepack/Read Text File
ComfyUI Node

Read Text File

Pulling prompts and configs off disk into the graph

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Read Text File
    • STRING
    dirinput
    file
    encodingutf-8
    ignore_errorsfalse

    Read Text File does exactly what the name says: it loads the contents of a text file off disk and hands them to your workflow as a STRING. If you've ever wanted to keep prompts in version-controlled .txt files instead of buried in a JSON workflow, or you want to read a config file, a list of keywords, or the output of some external script into the graph, this is the node. It's the boring utility that unblocks a dozen small conveniences.

    Here's the mental model: ComfyUI has a base path (the folder ComfyUI runs from). This node resolves your dir against that base path, then reads file inside it. The default dir is input - the same folder your images drop into - so dir=input, file=prompt.txt reads ComfyUI/input/prompt.txt. You can point it anywhere on disk with a relative path; it's a thin wrapper around Python's open().

    The inputs

    • dir - directory relative to the ComfyUI base path. Default input.
    • file - the filename. Empty by default, which is fine because it's on you to type the real name.
    • encoding - defaults to utf-8. The one you'll actually change is utf-8-sig when a Windows-created file has a stray BOM, or gbk/gb2312 for legacy Chinese text files - which, given the pack's author, is a real use case here.
    • ignore_errors - when on, unreadable characters are silently dropped instead of throwing. Handy for scraping weird files; you generally want it off so you notice corruption.

    The single output is STRING, which feeds any prompt box, text field, or the pack's LLM nodes. There's a whole pattern here: read a prompt from disk, pipe it into the LLM chat nodes to rewrite it, then feed the result into a text encoder.

    Install

    ComfyUI Manager → search "Duanyll Nodepack" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Duanyll/duanyll_nodepack
    cd duanyll_nodepack && pip install -r requirements.txt
    

    The node itself uses only Python's stdlib, but the pack's requirements.txt installs OpenCV, kornia, insightface, matplotlib, and the Volcengine SDK whether you want them or not.

    Gotchas

    The dir is relative to ComfyUI's base path, not to the node's own folder - a common first surprise if you assumed ./ meant the pack directory. And there's no folder browser dropdown, so the file has to exist at exactly the path you type; a typo just throws. Use ignore_errors as a blunt tool, not a habit.

    Honest verdict: ComfyUI's own Text nodes and a few bigger packs already read files (Impact Pack and friends have similar utilities), so you're not missing anything by skipping this. But if you're already installing Duanyll Nodepack for its LLM or Hugging Face loaders, this is a free, dependency-free addition that does the job cleanly.

    Categoryduanyll/loaders

    Inputs (4)

    NameTypeDefaultDescription
    dirSTRINGinput
    fileSTRING
    encodingoptSTRINGutf-8
    ignore_errorsoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    STRINGSTRING