Image metadata

How to read the prompt and settings from a Stable Diffusion image

The short answer

Most Stable Diffusion tools save the prompt and settings inside the image file itself. The AUTOMATIC1111 web UI and compatible forks write a text block named parameters into PNG files, and into the EXIF UserComment field for JPEG and WebP. ComfyUI writes prompt and workflow as JSON. NovelAI writes a JSON Comment and can also hide a copy in the PNG's alpha channel. A metadata viewer can read all of these. If the image was screenshotted, converted or re-encoded by a website, the data is usually gone and cannot be recovered from the pixels.

You found an image you like, or one of your own from months ago, and you want the prompt that made it. Often the answer is already inside the file. Image generators tend to write their settings into the file as metadata, next to the pixels, where a viewer can read them.

This guide explains where each popular tool stores that data, how to read a settings block field by field, why it so often disappears, and how far you can trust (and reproduce) what you recover. To read a file right now, drop it into our image metadata viewer. It reads the file's metadata in your browser and splits the prompt, negative prompt and settings into separate, copyable fields.

Where generation settings are stored

A PNG file is a sequence of chunks. Pixel data lives in the image chunks, and the format also allows text chunks, each holding a keyword and a string. That is the easiest place for a tool to put a prompt, so most do. JPEG and WebP have no text chunks, so tools use their EXIF or XMP metadata instead. The common layouts look like this:

ToolWhere the data sitsFormat
AUTOMATIC1111 web UI and forksPNG text chunk parameters; EXIF UserComment in JPEG and WebP; comment field in GIFPlain text block
ComfyUIPNG text chunks prompt and workflow; EXIF tags in animated WebPJSON
NovelAIPNG fields Software, Description and Comment, plus optional hidden alpha-channel dataPrompt as text, settings as JSON
InvokeAIPNG text chunks invokeai_metadata, invokeai_graph, invokeai_workflowJSON
FooocusPNG text chunks parameters and fooocus_schemeJSON or web UI style text

These names come from each project's source code, which you can read yourself: AUTOMATIC1111's web UI and InvokeAI are both open source. Formats can change between versions, so treat the table as a map that can go out of date.

The AUTOMATIC1111 parameters block

The Stable Diffusion web UI by AUTOMATIC1111 introduced the layout that most people mean by "PNG info", and many forks and other tools write the same one. It has up to three parts: the prompt, an optional Negative prompt: line, and one final line of comma-separated settings that starts with Steps:. Here is an invented example, written for this guide and not taken from a real file:

a quiet mountain lake at dawn, low mist, pine forest, soft light, photograph, <lora:mist_style:0.6>
Negative prompt: blurry, low quality, watermark, text, oversaturated
Steps: 28, Sampler: DPM++ 2M, Schedule type: Karras, CFG scale: 7, Seed: 1203948576, Size: 768x512, Model hash: 1a2b3c4d5e, Model: example_model_v1, Denoising strength: 0.45, Hires upscale: 2, Hires upscaler: Latent, Lora hashes: "mist_style: 9f8e7d6c5b", Version: v1.10.1

Reading the last line field by field:

  • Steps, Sampler, Schedule type, CFG scale: how the image was denoised and how strongly it followed the prompt. Older files often fold the schedule into the sampler name, such as DPM++ 2M Karras.
  • Seed: the starting noise. The same seed with different settings gives a different picture.
  • Size: width and height. When hires fix is on, this is the size of the first pass. The final image is larger.
  • Model hash and Model: which checkpoint was loaded. The hash is the first ten hexadecimal characters of the checkpoint file's SHA-256, so it identifies the exact file even if someone renamed it.
  • Denoising strength, Hires upscale, Hires upscaler: second-pass (hires fix) or image-to-image settings.
  • Lora hashes: short hashes for the LoRAs named in the prompt's <lora:name:weight> tags. The value contains a colon, so the web UI wraps the whole thing in quotes. Values that contain commas, colons or line breaks get the same treatment.
  • Clip skip, ENSD, RNG, Version: optional fields. Clip skip is only written when it is above 1, and RNG only when it is not the default GPU source. Extensions add their own entries to the same line.

No two files look exactly alike, because the settings line contains whatever the app and its extensions report. A parser has to find the last line that begins with Steps: and treat everything above it as prompt text. The web UI has a PNG Info tab that reads these blocks, and the viewer does the same for many files at once.

ComfyUI: the prompt and workflow chunks

ComfyUI saves two JSON documents. The workflow chunk is the full editor graph, including node positions and links, so the interface can rebuild your canvas. The prompt chunk is the stripped-down version the server actually executes, usually called API format. ComfyUI's documentation says dragging a generated image onto the canvas, or using File, Open, restores the graph when the workflow field is present.

The prompt text is not stored as a sentence. It sits inside the graph, as the text input of a text-encoding node. The settings sit in the sampler node. A shortened, invented example of API format shows how to find the positive and negative prompts:

{
  "3": {"class_type": "KSampler", "inputs": {"seed": 8675309, "steps": 20, "cfg": 7, "sampler_name": "euler", "scheduler": "normal", "denoise": 1,
        "positive": ["6", 0], "negative": ["7", 0], "model": ["4", 0], "latent_image": ["5", 0]}},
  "6": {"class_type": "CLIPTextEncode", "inputs": {"text": "a red bicycle leaning on a brick wall", "clip": ["4", 1]}},
  "7": {"class_type": "CLIPTextEncode", "inputs": {"text": "blurry, low quality", "clip": ["4", 1]}}
}

A pair such as ["6", 0] means "output 0 of node 6". Follow the sampler's positive link and you land on the positive prompt. A viewer can only guess from node order which text node is which, so when a graph has more than two text nodes (regional prompts, refiners, upscale passes), open the workflow in ComfyUI and follow the wires. The same documentation notes that this metadata does not include the models, inputs or custom nodes a workflow needs, and that it should be treated as optional, untrusted input.

NovelAI: the Comment field and hidden alpha data

NovelAI PNGs normally carry Software set to NovelAI, the prompt in Description, and a JSON Comment with fields such as uc (the negative prompt, which NovelAI calls undesired content), steps, scale, seed and sampler. This is the layout AUTOMATIC1111's own import code reads.

NovelAI's open-source metadata tools document a second copy, often called stealth metadata. Instead of a text chunk, the data is hidden in the alpha (transparency) channel: the lowest bit of each pixel's alpha value is read column by column, and the bits spell a short marker, a length, and gzip-compressed JSON. Some community extensions for other image tools offer a feature with the same goal under the name stealth PNG info. The point is that it survives when a site removes text chunks. The limits are strict, though. It only exists in lossless PNG files, and a change that alters the pixels or drops the alpha channel typically destroys it. Our viewer decodes this format as well.

How the hidden copy is laid out

The data starts at the top-left pixel and runs down the first column, then the second, taking the lowest bit of each value. The first bytes spell one of four markers, and the marker tells the reader where to look and whether to unzip:

MarkerBits taken fromData after the length
stealth_pnginfoAlpha channelPlain text
stealth_pngcompAlpha channelGzip-compressed
stealth_rgbinfoRed, green and bluePlain text
stealth_rgbcompRed, green and blueGzip-compressed

After the marker comes a 32-bit number giving the length of the data in bits, then the data itself. The room is easy to work out. An 832 × 1216 picture has 1,011,712 pixels, so the alpha channel holds 1,011,712 bits, about 126,000 bytes, and the RGB variants three times that. A settings block of a few kilobytes, gzipped, uses a small strip down the left edge.

Our viewer checks PNG and WebP files up to 40 megapixels for all four markers. Because the copy lives in the pixels, a metadata stripper leaves it alone: the metadata remover warns when it finds one and offers a "Re-save as JPEG" button, which re-encodes the picture and drops the alpha channel, and the hidden copy with it.

InvokeAI, Fooocus and web services

InvokeAI writes its own text chunks, so a tool that only knows the parameters layout shows nothing for it. Fooocus can write either a JSON or a web-UI-style parameters chunk, and records which in fooocus_scheme.

Hosted services are a different story. Midjourney, for example, documents a hidden ID tag in the images it delivers and offers a checker at midjourney.com/verify, but its documentation does not describe a prompt field in the file. Some web services put the prompt in a plain description field, and some put nothing at all. If your file has such a field, the viewer shows it. If it does not, the prompt is not in the file, and the place to look is your account's job history. Midjourney's documentation describes copying the prompt and job ID from its website. When a file does carry a description that ends in "Job ID:" and a long identifier, our viewer reads it as a Midjourney prompt and lists the prompt and the job ID on separate lines.

Reading a file in the viewer, step by step

Take a PNG that holds the example block from the AUTOMATIC1111 section above and drop it into the metadata viewer. This is what you see, in order:

  1. "What this file reveals" gets an information line: "Stable Diffusion web UI (v1.10.1) prompt and settings are stored in the file." The name comes from the Version field. A version that starts with f and a number, as Forge writes it, shows as Stable Diffusion WebUI Forge, and a block with no version shows as "AUTOMATIC1111, Forge or SD.Next format".
  2. The "AI generation info" group starts with Generator and Found in. Found in names the place the data came from: PNG text "parameters" here, or EXIF UserComment for a JPEG or WebP, PNG text "prompt" and "workflow" for ComfyUI, PNG text "Comment" and "Description" for NovelAI, PNG text "invokeai_metadata" for InvokeAI.
  3. Prompt and Negative prompt follow as separate long fields with copy buttons. The LoRA tag stays inside the prompt text, where it was written.
  4. Each setting gets its own row: Steps 28, Sampler DPM++ 2M, Schedule type Karras, CFG scale 7, Seed 1203948576 and so on. Quoted values lose their quotes, so Lora hashes reads mist_style: 9f8e7d6c5b.

For a ComfyUI file the settings rows come from the nodes instead: Seed, Steps, CFG, Sampler, Scheduler and Denoise from each sampler, plus Size, Checkpoint, Model, VAE, Guidance (for Flux graphs) and each LoRA with its strength, when the graph has those nodes.

Comparing a whole folder of renders

The viewer takes many files at once, and its all-files CSV export has four columns: File, Group, Field and Value, one row per field. Say you have 40 renders from a week of experiments and want to know which ones used a particular LoRA or seed. Drop all 40 in, download the CSV, open it in a spreadsheet and filter the Field column to Lora hashes, Seed or Model hash. Every file that has that field appears with its value. Files with no generation data have no such row at all, so a file name missing from the filtered list is one that lost its metadata along the way.

Why the metadata is missing

If you open an image and find nothing, one of these is almost always the reason:

  • It is a screenshot. A screenshot is a brand-new image with new pixels and no history.
  • It was re-saved or converted. Many editors, resizers and converters write a fresh file and carry over only some metadata. Converting PNG to JPEG or WebP usually drops text chunks.
  • A website re-encoded it. Plenty of sites recompress uploads and discard metadata. Behavior differs by site and changes over time, so test with one image before you rely on it.
  • The generator was told not to save it. The web UI has a setting named "Write infotext to metadata of the generated image", and ComfyUI has a --disable-metadata start-up flag. The web UI can also write the same text to a separate .txt file next to each image, so check the output folder.
  • Someone removed it on purpose. People strip prompts before sharing. A metadata remover such as our image metadata remover deletes text chunks, EXIF, XMP and Content Credentials without re-encoding the pixels. That is useful if you want to share a picture without your prompt and settings.

A missing prompt tells you nothing about how the image was made. A prompt that is present is only a claim, because anyone can type text into a metadata field. For the wider question of what metadata can and cannot prove, see our guide to Content Credentials and watermarks.

When the prompt is there but reads wrong

SymptomLikely causeWhat to do
Another program shows the prompt of a JPEG as a run of Chinese-looking charactersThe EXIF UserComment is marked UNICODE (UTF-16), and the program guessed the byte order wrongOpen it in our viewer, which tries both byte orders and keeps the one that reads as text
A ComfyUI file shows the wrong text as the prompt, or the two prompts swappedThe graph has several text nodes, or only the workflow chunk survived. With the prompt chunk the viewer follows the first sampler's wires; with only workflow it takes the first two text-encoding nodes in orderDrag the file into ComfyUI and follow the wires from the sampler
Two Seed or Steps rows for one ComfyUI pictureThe graph has more than one sampler, such as a base pass and an upscale passEach row is real. Check in ComfyUI which sampler produced the final image
ComfyUI is named but the prompt is emptyThe text was assembled by custom nodes the viewer cannot follow (it looks through up to eight links for a text, prompt or string input)Open the workflow in ComfyUI
Generator is named, Found in says "Software tag" or "XMP / IPTC source type", and there is no promptThe file names the tool that made it but stores no promptLook in the service's own history for the prompt
A JPEG you exported from an editor lost its promptThe editor rewrote the EXIF block without UserCommentExport again from the original PNG, or keep the PNG as your master copy

One structural limit is worth knowing when you choose a format. A JPEG's EXIF block has to fit in a single marker segment, whose length field is two bytes, so it holds at most 65,527 bytes of EXIF data. A prompt and a settings line fit easily. A whole node graph in JSON can be much larger, which is one reason graph-based tools keep to PNG text chunks, whose length field allows over two gigabytes.

Reproducing an image from the recovered settings

Copying the prompt, seed and settings into the same program gets you close to the original. It does not always give you the same pixels. These are the things that have to match:

  • The exact model files. Compare the model hash and Lora hashes against the files you have. A renamed file with the same hash is fine. A model of the same name at a different version is not.
  • Every setting on the line, including hires fix, clip skip and any extension settings, plus the prompt text with its emphasis syntax and LoRA tags.
  • The random number source. The web UI's own help text for its RNG option says that changing it changes seeds drastically, and that the CPU source is for getting the same picture across different graphics card vendors.
  • The software version. The web UI's wiki page on seed-breaking changes lists updates that make an old seed render differently, and most come with a compatibility option to restore the old behavior. PyTorch's documentation likewise says completely reproducible results are not guaranteed across releases, commits or platforms.

Metadata also leaves things out. Image-to-image inputs, inpainting masks, ControlNet reference images and custom nodes are not stored in full, so an image made with them cannot be rebuilt from the text alone. If you need the exact result, keep the original file. If you only need a similar one, the recovered prompt and settings are an excellent starting point.

Prompt syntax you will meet in recovered text

Prompts copied out of AUTOMATIC1111-style files are full of brackets and numbers that change how the text is weighted. The meanings below are the ones documented on the web UI's features page:

You seeIt means
(word)More attention to the word, by a factor of 1.1. ((word)) stacks to 1.21
(word:1.5)Attention multiplied by the number. Below 1 weakens it: (word:0.25) divides it by 4
[word]Less attention, divided by 1.1. A number only works inside round brackets
\( and \)Literal brackets, as in a character tag such as anime_\(character\)
[mountain:lake:16]Prompt editing: "mountain" until step 16, then "lake". A decimal such as 0.5 means a fraction of the steps
[cow|horse]Alternates between the two words on every step
BREAKMust be in capitals. Ends the current chunk of the prompt and starts a new one, padding the rest
<lora:name:0.6>Loads the LoRA file name at strength 0.6. LoRA tags cannot be used in the negative prompt
A bare unusual word, often in the negative promptPossibly a textual inversion embedding, which is used by typing its file name

Other programs support parts of this syntax. ComfyUI, for example, reads weights in the (word:1.2) form, but a prompt that relies on prompt editing or alternation will not behave the same everywhere. When you move a prompt between programs, strip the syntax the target does not understand, or it will be read as literal text.

Reusing prompts, and giving credit

A recovered prompt is a good way to learn how a style was built, and it makes a decent first draft of your own. It describes what the author asked for, not what the picture shows, so it is a poor caption for training data. If you are preparing a dataset, tag or caption the images themselves. Our guides to LoRA dataset captions and tags versus natural-language captions explain how.

If the image is someone else's, the prompt was part of their work. Crediting them when you share results, and checking the license of the site and models involved, is a considerate habit. This is etiquette rather than legal advice. More free image tools are listed on our tools page.

Put this into practice

See the EXIF, GPS location, copyright, Content Credentials and generation settings hidden inside any image, then export them as JSON or CSV. It runs in your browser. Open the Image Metadata Viewer.

Frequently asked questions

Does a JPEG or WebP keep the prompt?

Only if the program that saved it wrote it there. The AUTOMATIC1111 web UI stores its settings block in the EXIF UserComment field when it saves JPEG and WebP files. Most other tools do not, and converting a PNG to JPEG with an ordinary editor usually drops the text chunks. Our guide to EXIF data covers the rest of that metadata.

Does a settings block prove the image was made with Stable Diffusion?

No. The text is ordinary metadata, and anyone can paste a block into a file or edit the one that is there. Treat it as strong circumstantial evidence that falls short of proof. Signed provenance data is a different mechanism, covered in our guide to Content Credentials.

Can I read a prompt from an image I got from social media?

Only if the site kept the metadata, and many do not. Open the file you downloaded in the metadata viewer and see. If it is empty, the original uploader may still have the source file, or the prompt may be in the post text or the generator's job history. Screenshots never carry it.

How do I find the checkpoint or LoRA from its hash?

The ten-character model hash is the start of the file's SHA-256, so you can compare it with the hashes of files you already have. For files you do not have, Civitai's public API has a lookup by hash that accepts this short form (Civitai calls it AutoV2) as well as the full SHA-256. A match tells you which published file had that hash, so check its license before you use it.

Can I put a lost prompt back into a JPEG?

Yes, if you still have the text. Paste the whole block, including the Steps: line, into the User comment field of our metadata editor and save. That is the same EXIF field the AUTOMATIC1111 web UI uses for JPEG and WebP, so our viewer reads it back as generation data. It is your own note from then on: anyone reading it has no way to tell it was added later.