Nodes/ComfyUI-EreNodes/Prompt Extractor
ComfyUI Node

Prompt Extractor

Drag in an old PNG, get your prompt back as editable tags

By Erehr·Created about a year ago·Updated 4 days ago· 69
Prompt Extractor
    • STRING
    text
    prefix
    separator,\n\n
    image

    ComfyUI will already rebuild your entire workflow if you drag a PNG back onto the canvas. The Prompt Extractor does something narrower and arguably more useful: drag the image onto this node and you get just the positive prompt back - not as a frozen wall of text, but as editable tag pills you can toggle, reorder, restrength, and drag into your current prompt. It's the newest node in the EreNodes pack (added in v3.3), and it answers the eternal "wait, what prompt did I use for that image again?" without importing a whole graph you then have to untangle.

    It's also honest about what it does. The name might sound like it phones home somewhere - it doesn't. No API, no key, no model download. Every byte of it runs on your machine.

    How it actually works

    Every PNG that came out of ComfyUI's SaveImage carries the workflow inside it as text chunks - the readable workflow chunk (the editor graph you see) and the prompt chunk (the flattened graph that actually executed). AUTOMATIC1111 and Forge write a flat parameters string instead. The Extractor reads all of these, in a deliberate order:

    1. The workflow chunk first, when it contains EreNodes nodes - it's the only place your structured tag data survives, so toggled-off tags come back as inactive pills with their strengths intact.
    2. The prompt chunk (the executed graph) - authoritative about what really ran, and the only one present when the image was made through ComfyUI-as-API.
    3. A1111/Forge parameters and EXIF UserComment for PNG, JPEG, or WebP.

    Here's the clever bit: it doesn't just dump the graph's text. It traces backward from the sampler's positive input, walking the whole chain of text nodes (it even knows to follow prefix links, which is how chained EreNodes stay in order), and deliberately skips anything only reachable from negative. So no negatives, and no unconnected leftover text nodes cluttering your result - this is a graph reader, not a text scraper.

    Inputs and outputs that matter

    You mostly won't touch the inputs - the node is a drop zone. But here's the surface:

    • text (required, multiline) - the recovered prompt as a flat string. It's fully editable, and it's the transport: the pretty pills are the editor, this widget is what executes.
    • image (optional) - the file the prompt was recovered from, for reference. Drop a new one on the node to re-extract. Its tooltip says exactly that, and it means it.
    • prefix and separator - the same chaining inputs every EreNodes prompt node has. Feed another prompt node's string into prefix and the two get joined with the separator (default ,\n\n).

    The single output is a STRING: the combined prompt. Wire it straight into a CLIPTextEncode's text input, or into another EreNodes node's prefix to keep building.

    Installing it

    Via ComfyUI Manager: search "EreNodes", install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Erehr/ComfyUI-EreNodes.git
    # restart ComfyUI
    

    There are no model downloads and no heavy dependencies - the only declared Python dependency is safetensors, which ComfyUI already ships, and Pillow for reading the chunks. The bundled Danbooru/e621 tag dictionaries just live in __autocomplete__/.

    Gotchas worth knowing

    • Only the positive prompt comes back. That's by design, not a bug. If you want the negative, drag the image onto the canvas for the full workflow instead.
    • "No prompt metadata found in this image" is almost always the image's fault, not the node's. The metadata lives in text chunks, and any re-encode deletes it: Reddit recompresses uploads, so do Discord inline previews, and screenshots never had it. JPEG/WebP only keep a flat parameter string in EXIF. Keep the original PNG - that's the master.
    • Images from hosted generators (ComfyUI-as-API) only carry the prompt chunk, so extraction still works but you get flat text, not structured pills, and no inactive tags.
    • Missing-file warnings are real warnings: a LoRA or embedding pill gets a red border if the file it names isn't on disk. That's the pack catching a broken models/ path, not a render glitch.

    If you do a lot of tag-based prompting (think Danbooru-vocabulary models), this node slots right into the EreNodes workflow: extract, prune the pills you don't want, save the rest as a tag group, done. It's the rare metadata tool you'll actually reach for.

    CategoryEreNodes

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    prefixoptSTRING
    separatoroptSTRING,\n\n
    imageoptSTRINGImage the prompt was recovered from (for reference; drop a new one on the node to re-extract).

    Outputs (1)

    NameTypeDescription
    STRINGSTRING