Nodes/ComfyUI_PromptExtractor_nodes/DJZ Prompt Extractor (Path)
ComfyUI Node

DJZ Prompt Extractor (Path)

Prompt extraction, minus the image plumbing

By MushroomFleet·Created 7 months ago·Updated 5 months ago· 2
DJZ Prompt Extractor (Path)
    • prompt
    • negative_prompt
    • metadata_json
    image_path
    extraction_mode

    The whole point of the DJZ Prompt Extractor family is pulling the prompt out of a ComfyUI PNG without dragging the full workflow onto the canvas. This variant, DJZ Prompt Extractor (Path), is the version for when you already know where the file lives and you don't need the image to pass through the node.

    Why this variant exists

    The main extractor takes an image through a file-selector dropdown, like Load Image. That's handy, but it also drags an IMAGE output around even when you only want text. This node strips all of that away: one text field for the file path, no image handling, and the same extraction engine underneath. It's the honest, minimal version - which is also why the pack's batch node uses this one internally for every file it processes.

    You'd reach for it when the path is the natural thing you have: you're pointing at ComfyUI's own output folder, you have a path from a Load Image / file-list workflow, or you're building a text-only graph and don't want image tensors cluttering it. Feed it a path, get the prompt and negative prompt as plain strings, done.

    How it works

    Same mechanism as its sibling: ComfyUI embeds the full graph as JSON in the PNG's tEXt/iTXt chunks, the node opens the file with PIL and reads img.info, parses those JSON blobs, and pulls the text field from every CLIPTextEncode node it finds. Then it classifies positive vs negative using a keyword heuristic plus workflow connection tracing, falling back to "the longer string is probably the positive." Not perfect - the author says so - but right far more often than not.

    Inputs and outputs

    The inputs are a short list:

    • image_path - absolute path to the PNG. Absolute paths are strongly recommended; the README also warns to avoid special characters in the path.
    • extraction_mode - longest_string (default), positive_only, negative_only, or all_prompts. Use all_prompts when you suspect the classifier is guessing wrong.

    Outputs are prompt, negative_prompt, and metadata_json (the full parsed metadata, useful for double-checking what the node found). There's no image output on this one - if you need the pixels to keep flowing through your graph, use the main DJZ Prompt Extractor instead.

    Installing and gotchas

    Install is shared with the rest of the pack: ComfyUI Manager, search "DJZ Prompt Extractor", or:

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

    Restart after. No extra dependencies, no model files - this pack runs on PIL and the standard library alone.

    The one trap that catches people: the metadata only survives in the original PNG. If the image went through social media, got re-saved in an editor, or was converted to JPEG, the chunks are gone and this node returns nothing. There's no cleverness that can recover what the file no longer contains. Point it at the untouched output file and it behaves; point it at a re-upload and you'll get an empty string wondering what you did wrong.

    CategoryDJZ-Nodes

    Inputs (2)

    NameTypeDefaultDescription
    image_pathSTRING
    extraction_modeoptCOMBO4 options: longest_string, positive_only, negative_only, all_prompts

    Outputs (3)

    NameTypeDescription
    promptSTRING
    negative_promptSTRING
    metadata_jsonSTRING