ComfyUI Node

PromptLoader

Your prompt library as files, not as text boxes

By morino-kumasan·Created 2 years ago·Updated a day ago· 1
PromptLoader
    • PROMPT_FILE
    file

    PromptLoader is the front door of this pack. It reads a prompt file from disk and emits a PROMPT_FILE object that PromptDecode turns into a positive prompt, a negative prompt and a LoRA list. That's it - one dropdown, one output.

    The point of it is that your prompts become files you edit in an editor, not text boxes you scroll inside a node. Once you've written a TOML prompt with a base block, a dozen mix-and-match sub-blocks, character variants and per-variant LoRA tags, you will not want to maintain it in a canvas widget. You want it in a text editor with syntax highlighting, in version control, and reusable across every workflow you own.

    How it works

    At class-definition time the node walks its own prompts/ folder and builds a dropdown of every .txt, .toml, .yaml and .yml file it finds. That path is ComfyUI/custom_nodes/comfyui-toml-prompt/prompts/, which is where the pack ships a prompt.sample.toml worth reading end to end. One caveat the source makes obvious: the walk collects bare filenames and the loader later joins them straight onto the prompts root, so keep your prompt files at the top level of that folder - a file nested one directory down can show up in the dropdown and then fail to open.

    On execution it opens the file and hands back a PromptFile object, which keeps the raw text and the extension. The decoding itself happens downstream in PromptDecode; this node's only real logic is this:

    @classmethod
    def IS_CHANGED(cls, file: str):
        path = os.path.join(base_path, file)
        m = hashlib.sha256()
        ...
        return m.digest().hex()
    

    It hashes the file's contents and returns that hash as its "changed" signature. Which means ComfyUI's cache notices when you edit the prompt file, and re-runs the decode - the thing that makes an edit-and-queue loop work without a restart. If you're used to nodes that only re-run when an input wire changes, this is the difference.

    Extension handling is per the source: .toml and - surprising but useful - .txt are both parsed as TOML, and .yaml/.yml go through a YAML loader. A .txt prompt file that isn't valid TOML will throw at decode time.

    Inputs and outputs

    file - a single dropdown (tooltip: "file name."). One PROMPT_FILE output, wired into PromptDecode's toml input. It is not a STRING; you can't feed it to a text node, and you can't feed a STRING into PromptDecode instead.

    Install

    Manager search for the pack, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/morino-kumasan/comfyui-toml-prompt
    

    restart ComfyUI. Nothing to pip install - the repo's requirements.txt is empty - but note it needs Python 3.11+: the pack parses TOML with stdlib tomllib, which doesn't exist on 3.10 and older. YAML support rides on PyYAML, which ComfyUI already ships. The README's install block is stale (old comfyui-utils repo name, SSH clone URL), so use the HTTPS clone above.

    Where people get burned

    New files don't appear in the dropdown until you restart. The list is built once when the node class is loaded - reading from a folder ComfyUI may not have write access to surprises people. Create your .toml, then reload node definitions or restart before you go looking for it.

    Your prompts live inside the custom node folder. Update or reinstall the pack and you're trusting git to leave your files alone; prompts/.gitignore is set up for that, but "my prompt library is inside a node pack" is a portability decision worth making consciously. Back the folder up.

    Sharing a workflow no longer shares the prompt. The workflow references kitsune.toml by name; the other person's install doesn't have it. This is the standard "workflows need the exact same node packs" problem, and here it extends to the prompt files themselves - paste the TOML into a note node if you're publishing.

    Whitespace and encoding. The file is opened as UTF-8 explicitly; a TOML file saved as UTF-16 or with a BOM will fail to parse. Rare, but it happens when people edit prompts in Notepad.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    fileCOMBOfile name.

    Outputs (1)

    NameTypeDescription
    PROMPT_FILEPROMPT_FILEA Prompt.