ComfyUI Node

Load Text File

Load a .txt straight into your graph

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Load Text File
    • content
    • lines
    file_pathexample.txt

    Got a prompt, a negative list, or a settings file sitting on disk that you keep copy-pasting into your workflow? Load Text File reads a .txt file straight into the graph and hands you the whole content plus a line-split list. It's the node that turns "edit the text file, not the workflow" into reality - keep your long prompts or tag lists in a file, edit them there, and let the workflow just reference it.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. The mechanism is a plain open(file_path, 'r', encoding='utf-8') call - no models, no GPU, no external service.

    How it works

    One required input:

    • file_path - the path to the file (STRING, default "example.txt")

    Two outputs:

    • content - the entire file as one STRING
    • lines - the same text split into a LIST of lines (via splitlines(), so no trailing newline junk per entry)

    The path handling is the thing to understand: it uses whatever path you give it, resolved relative to ComfyUI's current working directory - which is typically the directory you launched ComfyUI from (usually the ComfyUI root). So file_path = "prompts/negative.txt" reads ComfyUI/prompts/negative.txt, and an absolute path like /home/you/notes.txt works too.

    Two friendly behaviors worth knowing: if the file doesn't exist, it returns "File not found: <path>" as the content (and an empty list) instead of crashing the graph. And if reading throws for another reason, you get "Error loading file: <detail>". Neither halts your workflow - which is convenient, but it does mean you can silently run with an error string in your prompt if you don't look.

    Where you'll use it

    • Long prompts and negative lists kept in editable text files.
    • Batch tag lists - split on newlines and feed lines into a list selector or Text Joiner.
    • Config-ish data loaded at runtime instead of hardcoded.

    Installing it

    Whole pack, one install. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. Requirements (numpy, torch, opencv-python) are already in stock ComfyUI; no model downloads. Don't confuse the pack with cubiq's "ComfyUI Essentials" when searching Manager - different, larger pack, in maintenance mode.

    Gotchas

    • Relative paths are relative to ComfyUI's working directory, not to your workflow file. If ComfyUI is launched from elsewhere, relative paths resolve elsewhere. Use absolute paths when in doubt.
    • Missing file doesn't error - it returns an error string. If your prompt looks wrong, check the content output; a "File not found" string in there is the tell.
    • UTF-8 only. A file in a different encoding will produce the "Error loading file" fallback.
    • It's a small, quiet pack - no big community writeups, but the behavior is plain enough to trust from the source.
    CategoryDebugPadawan/Utilities

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRINGexample.txt

    Outputs (2)

    NameTypeDescription
    contentSTRING
    linesLIST