Prompt Extractor From Dir (Inspire)
Reuse the Prompts Already Buried in Your Images
- positive
- negative
Every ComfyUI PNG you've ever saved has the whole workflow baked into its metadata. That's the undo button everyone knows about - drag the image back in and you get your graph back. What people forget is that it's also a prompt archive, and this node turns a folder of those PNGs into two lists of prompts your workflow can iterate over.
The use case is unglamorous and real: you have 200 images from a batch you liked, you want to re-render that batch with a different sampler or a new LoRA, and retyping 200 prompts is not happening.
What it does
Point directory at a folder, and for each image it parses the embedded workflow, finds every string input on every node, and reads the two you nominate. Then it sends the whole dump - one block per file, labelled with the filename - into the node's own info widget so you can read exactly what it found before trusting it.
The outputs are positive and negative, both STRING, and both lists. That's the important bit: one entry per image. In ComfyUI, a list output makes every downstream node run once per item, so CLIP Text Encode re-encodes and your sampler resamples for each prompt in the folder. Combined with Load Image List From Dir (Inspire) reading the same directory with the same settings, images and prompts line up index for index - that's the intended pairing, and the README calls it out.
Inputs
- directory - the folder of images. Relative paths resolve against ComfyUI's input directory, which is the usual source of "it found nothing".
- positive_id - the key of the text you want as positive. Not a node number: a
node_id.input_namepair, like6.text. Theinfobox lists every candidate in exactly that form, so you read the key off the dump and paste it in. - negative_id - same for negative.
- image_load_cap / start_index - how many images, and from where.
0means all of them. - sort_method -
None, alphabetical, numerical or datetime, ascending or descending. Use the same value here as on the image loader or the lists desynchronise. - load_always - reprocess the folder on every run instead of trusting the cache. Turn it on when you're adding images to the folder between runs.
The trap the README warns about
If a prompt in the original workflow came from another node - a Primitive string, a wildcard node, a prompt from a file - then what got saved is a link, not text. In the info dump it appears as something like ['12', 0], and the extractor returns an empty string for it, because there's no text there to return. The fix is to point positive_id at the node that actually held the text (node 12 in that example), not the encoder that received it.
Images with no prompt information at all aren't an error: they yield an empty string and keep their place in the list, so the pairing with the image loader survives. Empty text means "this one renders with whatever else is in your graph", which may or may not be what you want.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Inspire-Pack
pip install -r ComfyUI-Inspire-Pack/requirements.txt
Manager users: search "ComfyUI Inspire Pack", install, restart. No models, no extra packs. This node does depend on ComfyUI's server-side messaging to fill that info widget, so if the widget stays blank while the outputs work, you're usually looking at a stale browser cache after an update - hard-reload the page.
Practical notes
This is a batch tool, so watch the cost: 200 prompts means 200 full sampling runs unless something upstream short-circuits. image_load_cap exists for exactly this - set it to 5, prove the pipeline, then let it run.
It only reads ComfyUI's own metadata. A folder of A1111 PNGs, or images you stripped on export, gives you nothing useful. And since it reads the workflow rather than the prompt API form, a graph saved by a very old ComfyUI version may have keys in places you don't expect - another reason the info dump matters more than the fields do.
One last thing worth doing: because load_always forces a re-read, leaving it on defeats caching for everything behind it. Two-hundred-image folder plus load_always plus a random seed is how a coffee break turns into an afternoon.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | — | |
| image_load_cap | INT | 0 | — |
| start_index | INT | 00–18446744073709550000 | — |
| load_always | BOOLEAN | false | — |
| sort_method | COMBO | 7 options: None, Alphabetical (ASC), Alphabetical (DESC), Numerical (ASC), Numerical (DESC), Datetime (ASC), +1 | |
| positive_id | STRING | — | |
| negative_id | STRING | — | |
| info | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| positive | STRING | — |
| negative | STRING | — |