Image to Base64 Encode
Turn an IMAGE into a base64 string for APIs and webhooks
- image
- STRING
ComfyUI's IMAGE type is a tensor - great inside the graph, useless the moment you need to hand that image to something outside it: a JSON payload, a webhook, an API call that expects text, not a file. Image to Base64 Encode bridges that gap. It takes an IMAGE, encodes it in whatever format you pick, and hands back a base64 STRING you can drop straight into a request body.
The obvious use is anywhere your workflow needs to send an image rather than save it to disk - posting a result to a webhook, returning it inline from an API call, embedding it in a JSON structure alongside other metadata. It's a small node doing a genuinely common integration task that ComfyUI has no native answer for.
The inputs and outputs that matter
- image - the IMAGE to encode. Required.
- quality (optional, default 100) - only matters for lossy formats; PNG ignores it since PNG is lossless.
- format (optional, default
PNG) -PNG,WEBP, orJPG. PNG for lossless fidelity, WEBP or JPG when you want a smaller payload and can tolerate compression artifacts. - gzip_compress (optional, default off) - gzips the encoded string on top of base64. Shrinks large payloads, but whatever's receiving the string on the other end needs to know to gunzip it back before it's useful - this isn't something a generic base64 decoder undoes automatically.
- Output - STRING, the base64-encoded (and optionally gzipped) image data.
How it works
It encodes the image using PIL's standard save routines for the chosen format, base64-encodes the resulting bytes, and - if gzip_compress is on - gzips the payload before returning it as text. The result is plain ASCII, safe to embed directly in JSON or any other text-based payload.
How to install it
Ships with the full LogicUtils pack. Via ComfyUI Manager: search ComfyUI-LogicUtils, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/aria1th/ComfyUI-LogicUtils
then restart ComfyUI. No models to download; image encoding runs on the same PIL install ComfyUI already depends on, so there's nothing extra to fetch here.
Background on the pack: it's written by aria1th, publicly known as AngelBottomless, the trainer behind Illustrious XL - the SDXL anime finetune that displaced Pony Diffusion v6 as the open-source default. LogicUtils is his side project, and the README is upfront about where the docs stand: "Proper documentation is being prepared, however there are too many nodes." That's held since the repo's last push in early 2026. It's a real, used pack all the same - it turns up as a dependency in complex published workflows next to rgthree-comfy and comfyui-kjnodes - just under-documented, which is what this article is for.
Common issues & troubleshooting
The output string is enormous. Base64 inflates data size by roughly a third over the raw bytes, and PNG at high resolution is already large before that. Switch format to WEBP or JPG and drop quality if payload size matters more than pixel-perfect fidelity, or turn on gzip_compress.
The receiving service can't decode it. If gzip_compress is on, the receiver needs to gunzip before base64-decoding - a plain base64 decode on gzipped data just gives you compressed garbage, not an image. If size isn't a real problem, leave gzip_compress off and skip the extra step entirely.
Expected to get an IMAGE back out somewhere downstream. This node only encodes; it's a one-way trip to STRING. This pack's Base64 to String Decode node is the counterpart, but it decodes back to STRING too, not to an IMAGE - there's no base64-to-image node in this set to round-trip an image back into the graph.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| qualityopt | INT | 100 | — |
| formatopt | COMBO | PNG | 3 options: PNG, WEBP, JPG |
| gzip_compressopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |