ComfyUI Node

DJZ Prompt Extractor

Lost the prompt? This node digs it out of the PNG

By MushroomFleet·Created 7 months ago·Updated 5 months ago· 2
DJZ Prompt Extractor
    • prompt
    • negative_prompt
    • metadata_json
    • image
    image
    extraction_mode

    You made something great, closed ComfyUI, and now the prompt that produced it lives only in the PNG file. Or someone posted an image you want to recreate and there's no workflow attached. The stock ComfyUI answer to both is "drag the image onto the canvas" - that reconstructs the entire graph, which works, but drops a full workflow on you when all you actually wanted was the text. DJZ Prompt Extractor is the leaner route: point it at the PNG and get the positive prompt, the negative prompt, and the raw metadata out as plain strings you can copy, wire into a CLIP Text Encode node, or paste into a fresh workflow.

    What's actually happening

    ComfyUI does a genuinely clever thing: every output PNG carries the full generation graph embedded in its file metadata. The workflow and prompt data live as JSON strings in the PNG's tEXt and iTXt chunks - the same mechanism that made "workflow included" a community norm in the first place. This node reads those chunks with PIL, parses the JSON, finds every CLIPTextEncode node inside, and pulls the text field from each one.

    Then comes the part the name oversells slightly: splitting prompt from negative. It's a heuristic, not a parser. The node counts negative-ish keywords (ugly, blurry, watermark, deformed, that familiar list), and it also traces the workflow to see whether a given encoder feeds a sampler's positive or negative input. If neither method commits, it falls back to "longer string is probably the positive prompt." That's reasonable most of the time, and wrong sometimes - the README says as much, and it's why all_prompts mode exists.

    The inputs that matter

    • image - a file-selector dropdown, exactly like Load Image. Drop your PNG into ComfyUI's input folder (or use the upload button). This is the whole trick: because the node re-opens the actual file from disk, it has access to the metadata. If you feed it an image that's been through a pipeline as a tensor, there's nothing left to read.
    • extraction_mode - four options: longest_string (default), positive_only, negative_only, all_prompts. The last one is your debugging friend: it dumps everything found, joined with |, so you can see what the classifier was working with.

    Outputs

    • prompt and negative_prompt - the classified strings. Wire prompt straight into a CLIP Text Encode node to re-run a generation, or into a Show Text node to eyeball it.
    • metadata_json - the full parsed metadata as pretty JSON. When something looks off, this is where you verify.
    • image - the image itself passes through as a tensor, so the node plays nice in the middle of a graph without breaking your flow.

    Installing it

    ComfyUI Manager, search "DJZ Prompt Extractor", hit install. Or the manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MushroomFleet/ComfyUI_PromptExtractor_nodes
    

    Then restart ComfyUI. That's the entire install - this is one of the rare packs with no extra dependencies (requirements.txt is effectively empty; it uses PIL and the standard library, both already in ComfyUI) and no model downloads. It's a small solo-dev pack from MushroomFleet, a port of the author's browser-based JSX extractor, so keep expectations calibrated: it's a utility, not a heavyweight suite.

    Where people get burned

    Empty output is almost always a metadata problem, not a bug. Social media, image hosts, re-saving in an editor, and conversion to JPEG all strip the tEXt chunks. You can only recover the prompt from the original output file. If you get nothing, that's the first thing to check.

    Misclassification. Unusual workflows and unconventional negative prompts defeat the heuristic. Switch to all_prompts to see everything the file contains, and check metadata_json for the raw data.

    File not found. Use absolute paths, and steer clear of special characters in the path - the README flags both.

    If you find yourself constantly fighting the classifier, skip to the V2 version in the same pack (DJZ Prompt Extractor V2). It drops classification entirely and instead ranks every string by length so you pick the one you want by position - a better fit for messy metadata.

    CategoryDJZ-Nodes

    Inputs (2)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    extraction_modeoptCOMBO4 options: longest_string, positive_only, negative_only, all_prompts

    Outputs (4)

    NameTypeDescription
    promptSTRING
    negative_promptSTRING
    metadata_jsonSTRING
    imageIMAGE