Caption Load Node
Caption Load Node
- captions
You've got captions sitting on disk as text files - hand-written for a LoRA set, or generated by a captioning model. Now you want them inside the graph, so you can feed them to a sampler one at a time, shuffle through them, or run them through a prompt enhancer. That's the whole job of Caption Load Node, and it's about as simple as a node gets.
Point the single input, captions_dir_or_file, at either a directory or a single text file, and it hands you a captions output you can wire onward. The behavior depends on which you give it:
- A directory - every file inside becomes one caption. This is the mode for a LoRA training folder where each image has a matching
.txt. - A single file - every line becomes one caption, with blank lines dropped. This is the mode for a prompts list you keep around for iteration.
That's it. One input, one output, no knobs to fiddle.
How it actually works
The code reads the path, and then it caches. It only reloads when the path string changes. That means if you edit a caption file on disk without touching the node, the graph keeps serving the old list until you change the path (even a dummy edit forces a reload) or restart ComfyUI. Keep that in mind when you're iterating on captions mid-workflow - it looks like a bug, but it's a deliberate caching choice.
Two behaviors worth knowing about:
- It dedupes - if a caption is already in the list, it won't be added again. Two identical caption files become one entry. Usually harmless, occasionally surprising.
- File order follows
os.listdir, which is not guaranteed sorted. If ordering matters (it does when you're pairing captions to images by position), zero-pad your filenames so the read order is what you expect.
One schema quirk: the output is typed STRING in the schema, but it's really a list of strings. That's fine as long as you feed it to nodes that expect the list - the pack's own Caption Select Node is built for exactly that, and it's the natural next stop: CaptionLoad → CaptionSelect → your text encoder.
Installing the pack
ComfyUI Manager: Custom Nodes Manager → search ComfyUI-LLMNodes → install. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/LatentGEN/ComfyUI-LLMNodes
Restart after installing. The pack ships with an empty requirements.txt and no declared dependencies, so there's nothing to pip install for this node - the utility nodes are pure Python. That's also your cue that this is a young pack (no README, no community footprint behind the author) - read the code if you plan to depend on it, it's only a few hundred lines.
Troubleshooting
- Node returns nothing / an empty list - check that the path is absolute and actually points at a folder containing text files. The node prints errors like "File not found" to the ComfyUI console rather than raising in your face, so look there.
- Stale captions after editing files on disk - you've hit the cache. Change the path value (even a space) and it reloads.
- Wrong order - that's
os.listdir; rename files with zero-padded indices.
It's a boring utility node, and boring is a compliment here. It loads what you point it at, dedupes quietly, and stays out of the way.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| captions_dir_or_file | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| captions | STRING | — |