Nodes/ComfyUI_PromptExtractor_nodes/DJZ Prompt Extractor V2
ComfyUI Node

DJZ Prompt Extractor V2

Prompt extraction that stops guessing — pick by position instead

By MushroomFleet·Created 7 months ago·Updated 5 months ago· 2
DJZ Prompt Extractor V2
    • selected_string
    • all_strings_json
    • total_count
    • debug_info
    • image
    image
    offset1
    ignore_system_prompttrue

    The V1 extractor's dirty secret is its classifier. It decides what's a "positive" prompt and what's a "negative" one using keyword matching and workflow tracing, and when it's wrong, you're stuck with empty or swapped outputs. DJZ Prompt Extractor V2 is the author's answer to that: stop classifying, start ranking. It digs every string out of the PNG's metadata, sorts them by length, and lets you pick which one you want with a single offset number. Longest string, second longest, whatever - you dial it in instead of trusting a heuristic.

    How it works

    Same foundation as before: ComfyUI stores the graph as JSON in the PNG's tEXt/iTXt chunks, and the node reads those via PIL. But where V1 hunts specifically for CLIPTextEncode nodes and then guesses at positive vs negative, V2 recursively collects every string in the metadata, joins segmented widgets_values prompts back together, deduplicates, and sorts the lot by length, longest first. offset is then just an index into that list: 1 = longest, 2 = second longest, and so on.

    There's one genuinely useful filter hiding in here: ignore_system_prompt (on by default). Newer workflows - the Wan / LLM-encoder generation - stuff giant system prompts into the metadata, and those are always the longest strings. Without the filter, offset 1 would hand you the system prompt every time and you'd think the node was broken. The filter detects and removes that content before ranking, and debug_info tells you how much it filtered out.

    Inputs

    • image - file-selector dropdown, same Load Image style as V1. Original output PNGs only; the metadata is gone from anything re-saved or uploaded.
    • offset - which string to return, 1–100, default 1. This is the input you'll actually be fiddling with. If you pick an offset past the end, it clamps to the last string and says so in debug_info.
    • ignore_system_prompt - true by default. Leave it on unless you specifically want the system prompt.

    Outputs

    • selected_string - the string at your offset. Wire this into a CLIP Text Encode node or a Show Text node.
    • all_strings_json - a JSON array of every string found, each with its index, length, and a preview. Feed this to the pack's String Navigator node to browse them without re-opening the file.
    • total_count - how many strings were found.
    • debug_info - what the node found and filtered; the first thing to check when a result looks wrong.
    • image - pass-through tensor, so it stays graph-friendly.

    Installing and the honest take

    Same pack install, same trivial cost: ComfyUI Manager search "DJZ Prompt Extractor", or cd ComfyUI/custom_nodes && git clone https://github.com/MushroomFleet/ComfyUI_PromptExtractor_nodes, then restart. No dependencies, no models.

    Honest take: for a single image, dragging it into ComfyUI gives you the whole workflow and prompt for free - that's the community's stock answer and it's a good one. V2 earns its place when you want just the text without the graph, when the classifier in V1 keeps betraying you, or when you're dealing with video-era workflows where the metadata is a haystack of strings and you need to cycle through them by position. That last case is where V2 genuinely beats everything else in this pack.

    CategoryDJZ-Nodes

    Inputs (3)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    offsetoptINT11–100Which string to return: 1=longest, 2=second longest, etc.
    ignore_system_promptoptBOOLEANtrueFilter out system_prompt content from results

    Outputs (5)

    NameTypeDescription
    selected_stringSTRING
    all_strings_jsonSTRING
    total_countINT
    debug_infoSTRING
    imageIMAGE