Extract Metadata Text
Get the prompt back out of anyone's ComfyUI PNG
- extracted_text
Every ComfyUI PNG carries its whole workflow inside the file. Drag that PNG back into ComfyUI and the graph rebuilds itself - that's the "workflow included" culture, and it's why ComfyUI won. The catch: you get the graph, not the prompt as a plain string you can copy or reuse. Extract Metadata Text is the tiny tool that hands you the text back.
It's one half of a two-node pack. Its partner, Load Image with Metadata, is what actually reads the workflow text chunk out of the PNG and passes it down the wire as a string. This node takes that string, digs the prompt out of the embedded JSON, and returns it as clean text you can paste into your own CLIP Text Encode node, drop into a text file, or feed anywhere else a prompt string belongs. On its own it's useless; wired after Load Image with Metadata, it's the missing "undo" button for "I want that prompt."
How it works
The mechanism is simpler than the concept. ComfyUI saves two things into a PNG's metadata: a prompt chunk (the API-format graph) and a workflow chunk (the full editor graph with widget values). Load Image with Metadata reads the workflow key and hands it to this node. Extract Metadata Text then:
- Parses that string as JSON.
- Scans the graph's nodes for ones whose type matches a text node it knows: the built-in CLIP Text Encode (Prompt) (
CLIPTextEncode), Display Any from rgthree, or Show Any from comfyui-easy-use. - Pulls the node's
widgets_values- the actual text you typed - and returns it.
One detail worth knowing: easy-use's Show Any stores its text one list layer deeper than the others, and the node unpacks that automatically. It only does this for the simple single-value case, which is fine in practice.
The inputs that matter
There are only two, and you'll only ever touch one:
workflow_metadata(required) - the string from Load Image with Metadata. That's the only sane thing to feed it.node_id(optional, default0) - 0 means "auto-detect." If your graph has exactly one supported text node, you never touch this. If it has more than one, auto-detect throws an error that helpfully lists the discovered node IDs - set this to the one you want.
The single output, extracted_text, is a plain STRING. Wire it to a Show Text / Preview Text node to eyeball it, or straight into a text primitive that feeds your own sampler.
Installing it
ComfyUI Manager is the clean route: search for comfyui-metadata-nodes and install. Or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/DarkStarSword/comfyui-metadata-nodes
Then restart ComfyUI. The README says "copy this folder" - ignore that; git clone does the same thing and stays updateable. No model downloads, no heavy dependencies. The pack imports PIL, numpy and torch, but those are already part of ComfyUI itself, so there's nothing extra to babysit.
Where people get burned
- The built-in Load Image won't work. It loads the image but never exposes the workflow string, so this node has nothing to chew on. You must use Load Image with Metadata, which lives in the same pack - install them together.
- Only three node types are understood. If the image's workflow used Flux-style prompt nodes, an SD3 prompt node, or any of the hundred other text encoders, this node reports zero compatible nodes and errors. It's a focused tool, not a universal prompt extractor.
- Images without an embedded workflow give you
Noneinstead of a JSON string, and the parse fails. Check the image actually has metadata before wiring it up. - Multiple prompts, wrong prompt. That's the
node_iderror above - read the listed IDs and pick the right one.
It's a niche, zero-hype utility (the pack has barely any community footprint, and bigger metadata-extractor packs that also read A1111 PNGs exist if you need that). But for "I grabbed this PNG, give me the words," it's dead simple and it works.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| workflow_metadata | STRING | ComfyUI workflow metadata string from LoadImageWithMetadata node | |
| node_idopt | INT | 0 | Node ID of the text node (0 for auto-detect) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| extracted_text | STRING | — |