ComfyUI Node

Save Image & Base64 Output

Save the PNG, and get the base64 string free

By GrailGreg·Created about a year ago·Updated about a year ago· 2
Save Image & Base64 Output
  • images
  • base64
filename_prefixComfyUI

ComfyUI's stock SaveImage writes a file to disk and calls it a day. Fine for most people. But the moment you want to hand an image to a web app, a webhook, or a node that eats strings instead of pixels, that file isn't enough - you want the image as text. SaveImage64 (from GrailGreg's small images_base64 pack) is the stock SaveImage with one extra trick: it saves the PNG exactly like the original, then hands the whole thing back to you as a base64-encoded string you can wire anywhere a STRING input goes.

Why you'd reach for it

Normally, images leave ComfyUI as files, or as base64 blobs you fetch from the server's /view endpoint after a run. That's fine when your code drives ComfyUI. But if you want the string to exist inside the graph - so a downstream node can push it to a Discord bot, a captioning service, an object-detection API - this is the node that puts it there. It removes a whole class of "the image exists but I can't get to it" friction, which is exactly the kind of glue the custom-node ecosystem exists for.

How it works

It's a subclass of the stock SaveImage logic, and it shows. It converts the IMAGE tensor (0–1 floats) to a uint8 image, saves each item in the batch as a PNG into ComfyUI's normal output folder with the usual {prefix}_00001_.png naming, and embeds the prompt and workflow into the PNG metadata - that "drag the image back in and the graph rebuilds" trick ComfyUI is famous for. Then it takes the exact same bytes, base64-encodes them with Python's stdlib, and returns them as the node's output.

One detail worth knowing before you run a grid: a single image gives you one clean string, but a batch of four gives you four strings joined with commas. Fine if your downstream knows to split on commas. Decidedly un-fun if it doesn't.

The inputs and outputs that matter

Just two inputs, and you'll set one of them:

  • images - the IMAGE tensor. Feed it from a VAE Decode or Load Image.
  • filename_prefix - a string, default ComfyUI. The file lands in output/ as {prefix}_00001_.png, so give it a recognizable name if you generate a lot.

The single output is base64 (a STRING), which is the whole point. Wire it into any text input downstream.

Install

No dependencies, no model downloads - just Python stdlib plus the PIL/numpy ComfyUI already ships. ComfyUI Manager: search "images_base64" (or the pack title, "Image Saving and Base64 Encoding Script"), install, restart. It's registered on the Comfy Registry, so Manager treats it as a normal catalog pack. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/GrailGreg/images_base64

Then restart ComfyUI. You'll find SaveImage64 under the image category, right next to the stock SaveImage.

Where people get burned

  • The string is huge. Base64 adds ~33% on top of the PNG, and a 1024×1024 PNG is already 1.5–2 MB. A multi-megabyte string in the graph is normal here. Don't dump it into a widget and expect prettiness.
  • Batch output is comma-joined. There's no splitter in this pack, so if you feed a grid you get one giant comma-separated string to deal with elsewhere.
  • The workflow metadata always goes in. The pack vendors its own copy of ComfyUI's argument parsing, hardwired to defaults, so --disable-metadata never reaches it. Your PNGs carry the full prompt and workflow - the same privacy note as stock SaveImage, just without the easy off switch.
  • It's an output node, but the string still wires onward. OUTPUT_NODE just means it's safe as a terminal; you can still drag base64 into a text or HTTP node.

Honest caveat: this is a tiny, nearly unknown pack - zero Google impressions, nothing on Reddit. You're not installing it for street cred; you're installing it because you specifically need base64 inside the graph. For that job it works, it's dependency-free, and it behaves like the stock node you already trust.

Categoryimage

Inputs (2)

NameTypeDefaultDescription
imagesIMAGEThe images to save.
filename_prefixSTRINGComfyUI

Outputs (1)

NameTypeDescription
base64STRING