Single image to base64
Turn a rendered image into a string your HTML can actually show
- images
- base64Image
Every now and then you need an image that isn't a file. You need it as text. Single image to base64 takes the first image in a batch, encodes it as a base64 string, and hands you back a data:image/png;base64,.... URI - the format you can paste straight into an <img src="..."> tag. The pack's own example workflow spells out the use case: an HTML string with <img src="HERE"/> sitting in it, waiting for one of these.
Why bother? Two classic reasons. Email clients block or refuse to load external images all the time, so embedding the pixels inline is the reliable way to make a generated image actually appear in an email or a self-contained HTML page. And base64-as-string is how images travel over APIs and through text-oriented nodes - the same reason people building API-driven ComfyUI frontends end up encoding images this way. If a string is where your image needs to be, this is the node.
How it works
The mechanism is a short, honest pipeline: the node takes images[0] - the first image off the wire - converts the PyTorch tensor to a PIL image, saves it as a PNG into an in-memory buffer, base64-encodes those bytes, and returns them with the data:image/png;base64, prefix. A utility copied straight from the comfyui-easyapi-nodes project, which tells you everything about where this pattern comes from: the API-workflow world.
The inputs and output
images- a standardIMAGEtensor, the kind every sampler and VAE decode outputs. Note the "single image" in the name: it only encodes the first frame of the batch. A batch of four becomes four runs or one unfortunate first image, not four encodings.- Output:
base64Image, aSTRING. Paste it into an<img src>attribute, wire it into anything that accepts strings, or hand it to a node that posts it somewhere.
Install
Search ComfyUI_html in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/filipemeneses/ComfyUI_html
Then restart. No models, no dependencies beyond what ComfyUI already ships.
Where people get tripped up
Base64 of a PNG is big. A 1024×1024 render lands around 2–3 MB of text - you will not want to look at that string in a node widget, and if you're putting it in an email, your email just got heavier. It's also a fresh re-encode of the tensor, which means the output carries no workflow metadata: drag the decoded image back into ComfyUI later and you'll get pixels, not a graph. If keeping the workflow matters, reach for the keep metadata variant. And remember the first-image-only rule - if your batch isn't a single image, what you get back is not what you think you encoded.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| base64Image | STRING | — |