Nodes/SD Prompt Reader/SD Prompt Reader
ComfyUI Node

SD Prompt Reader

Read the prompt out of any Stable Diffusion image — even ones ComfyUI never made

By receyuki·Created 3 years ago·Updated 2 years ago· 463
SD Prompt Reader
    • IMAGE
    • MASK
    • POSITIVE
    • NEGATIVE
    • SEED
    • STEPS
    • CFG
    • WIDTH
    • HEIGHT
    • MODEL_NAME
    • FILENAME
    • SETTINGS
    image
    parameter_index0

    ComfyUI is great at exactly one kind of metadata: its own. Every PNG it saves carries the full workflow graph as a JSON blob, and drag that image back in and the whole pipeline reconstructs. But that JSON is a closed club. Civitai, A1111, and most prompt-reader tools don't read it - they look for the A1111-style parameters text chunk instead. SDPromptReader is the node that reads that chunk, and it's the flagship of the SD Prompt Reader pack by receyuki, the same person behind the standalone desktop tool of the same name that people have been dragging images into since 2023.

    What it actually reads

    The node uses the same ImageDataReader engine as the standalone SD Prompt Reader, so it's not fussy about where an image came from. It handles PNG, JPEG, WebP, and even raw .txt metadata files, across A1111, ComfyUI, NovelAI (both stealth and legacy), InvokeAI, Easy Diffusion, StableSwarmUI, Fooocus-MRE, Draw Things, and Naifu. Grab a random image off Civitai that was made in A1111 and drop it in - that's the sweet spot. ComfyUI alone can't do that.

    Two inputs exist and one of them matters. image is a dropdown of whatever's in your input folder with an upload option, same as the built-in Load Image. parameter_index is the one that bites people: images that went through hires-fix or a refiner can carry multiple sets of parameters, and this selects which set you're reading. If you ever see a "list index out of range" error or get garbage values out of a two-stage image, this is the culprit - bump the index.

    The outputs are where the node earns its keep. The ones you'll actually wire somewhere:

    • POSITIVE and NEGATIVE - strings you can feed straight into a CLIP Text Encode node to reuse a prompt.
    • SEED, STEPS, CFG, WIDTH, HEIGHT - typed numbers, not text, so they drop into a KSampler without conversion.
    • MODEL_NAME - this one's clever. It takes the model name from the metadata and matches it against your installed checkpoints, preferring identical path, then identical filename+extension, then just the stem. If nothing matches, you get the original string back. It's typed as a wildcard so it slots into a CheckpointLoader's output.
    • SETTINGS - the raw parameter block, which you hand to the pack's SD Parameter Extractor for anything the node doesn't expose.
    • IMAGE and MASK pass through so you can do something with the image itself downstream.

    One thing worth knowing for SDXL: if the metadata stores separate text_g and text_l prompts, the reader combines them into a single POSITIVE output rather than making you deal with two strings. On the reading side, that's convenient; on the writing side you'll need the Prompt Merger node for the reverse.

    Installing it

    ComfyUI Manager handles it - search "SD Prompt Reader" and install. Manually, the one catch is that you must clone recursively, because the parsing engine lives in a submodule:

    cd ComfyUI/custom_nodes
    git clone --recursive https://github.com/receyuki/comfyui-prompt-reader-node.git
    cd comfyui-prompt-reader-node
    pip install -r requirements.txt
    

    Then restart ComfyUI. A plain git clone without --recursive gives you a pack with no reader inside it, and updating means git pull --recurse-submodules. The README warns against the ZIP download for exactly this reason. The only dependency is piexif, so no model downloads and no GPU load.

    When it lets you down

    Two failure modes are worth knowing. Images from heavily custom-node workflows can trip a "complex workflow" error - the embedded workflow confuses the reader, and the README's fix is to build outputs with the pack's own SD Prompt Saver so the metadata is written cleanly in the first place. And if the file simply isn't in a supported format, you get a FORMAT_ERROR and empty outputs instead of a crash. Not ideal, but it won't take down your whole graph.

    CategorySD Prompt Reader

    Inputs (2)

    NameTypeDefaultDescription
    imageCOMBO1 options: example.png
    parameter_indexoptINT00–255

    Outputs (12)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK
    POSITIVESTRING
    NEGATIVESTRING
    SEEDINT
    STEPSINT
    CFGFLOAT
    WIDTHINT
    HEIGHTINT
    MODEL_NAME*
    FILENAMESTRING
    SETTINGSSTRING