Prompt Block Loader
Edit Your Prompt Blocks in a Text File, Not Inside the Graph
- block1
- block2
There's a workflow itch that Prompt Block Loader scratches: you've got long, structured prompt chunks that you'd rather edit in a text editor than inside a ComfyUI node's cramped multiline box - and you want the graph to pick up the changes without touching the workflow. It reads a plain .txt config file, extracts two named "blocks," and outputs them as two strings. Edit the file, save, re-run, done. No graph editing.
It's from artyclaw/artyclaw-comfy. Given how prompt engineering has shifted toward "structure your prompt in blocks" (the KB's own prompt-engineering doc calls block structure a genuinely new best practice for LLM-encoded models), this is the pack's most future-facing IO node.
How it works
The config file is a simple line format:
# comments are ignored
!myblock1
a red car on a mountain road
golden hour, low angle
!myblock2
shot on 35mm, shallow depth of field
A header line !<name>1 or !<name>2 starts a block (the trailing digit is part of the header), content runs until the next ! header or the end of file, and # lines are skipped. The node builds keys from (blockname, "1") and (blockname, "2"), so with blockname = "myblock" it returns the content under !myblock1 and !myblock2.
The nice touch is cache handling: the node's IS_CHANGED hook reports the config file's modification time, so ComfyUI automatically re-runs it when the file changes on disk. No manual "reload" ritual. The optional force_reload toggle exists for when you want to bypass that timestamp check anyway.
Inputs and outputs
- config_path - path to the config file, relative or absolute (default
prompt_blocks.txt, relative to the ComfyUI working directory). - blockname - the base name whose
1and2blocks you want (defaultmyblock). - force_reload (optional) - bypass the file-timestamp cache.
Outputs are block1 and block2 (both STRING). Missing blocks return empty strings rather than erroring.
Install
ComfyUI Manager → search ArtyClaw Comfy Nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/artyclaw/artyclaw-comfy
Restart. Pure Python (os, re, time).
Where people get burned
Relative paths resolve against ComfyUI's working directory, not the node's folder - so prompt_blocks.txt ends up wherever you launched ComfyUI from, which surprises people the first time. Second, the block-name matching is exact and case-sensitive: !MyBlock1 won't match blockname = myblock. Third, the header regex only allows letters, digits, underscores, and hyphens in the name - a space in your block name silently never matches. And the two-block limit is hardcoded; if you have ten blocks, this node isn't the one - it's specifically for a pair you want to keep editing outside the graph. For that narrow, very real need, it's excellent.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| config_path | STRING | prompt_blocks.txt | Path to the config .txt file (relative or absolute). |
| blockname | STRING | myblock | Base block name to fetch: will output <blockname>1 and <blockname>2. |
| force_reloadopt | BOOLEAN | false | Force reload even if file timestamp hasn't changed. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| block1 | STRING | — |
| block2 | STRING | — |