Nodes/ComfyUI_Dados_Nodes/Image to Base64
ComfyUI Node

Image to Base64

Turn any ComfyUI image into a string the rest of the world can read

By DadoIrie·Created 2 years ago·Updated a day ago· 10
Image to Base64
  • image
  • base64_string

ComfyUI thinks in tensors; almost everything else on the internet thinks in base64. Image to Base64 is the adapter between the two: you feed it an IMAGE tensor and it hands you back a base64-encoded string of the image, ready to paste into an API request, a JSON payload, a webhook, or a file dump. It's the kind of node you reach for exactly once per project - and then wonder how you'd have done it without it.

How it works

The node takes your image tensor, converts it from the 0–1 float range ComfyUI uses back to 0–255 bytes, encodes it as a PNG, and base64-encodes the result. Two details from the source are worth knowing:

  • The image is encoded as PNG, so it's lossless - no quality setting, nothing to tune. A 768×1152 render turns into a long string, but it's the exact pixels you rendered.
  • If you feed it a batch of images, it encodes each one and joins them with commas into a single string. The reverse node in this pack (Base64 to Image) splits on those same commas, so the two are a clean round-trip pair.

The input and output

One input: image (an IMAGE tensor). One output: base64_string (a plain STRING). No settings, no format choice, no surprises. It's a pure function.

Where it actually shows up in workflows

The practical use case is talking to anything outside ComfyUI:

  • Building a JSON payload for an API call - a custom endpoint, a vision model, a prompt-eval service - where the image has to travel as text.
  • Saving a render's base64 to a file or a variable for later reuse instead of as a PNG on disk.
  • Round-tripping through a string-based stage of a graph (a node that only accepts strings) and coming back in with Base64 to Image.

Pair it with a string-to-file node or a "print to console" node and you've got a quick way to inspect exactly what an image looks like as data. If your end goal is just saving the image, use a normal save node - this produces a string, not a file, and a giant base64 blob in your workflow JSON will bloat your saved workflows noticeably. Keep it on its own line, or only wire it where a string is genuinely required.

Install

It ships with the Dados Nodes pack: ComfyUI Manager → search "Dados Nodes", or

cd ComfyUI/custom_nodes
git clone https://github.com/dadoirie/ComfyUI_Dados_Nodes.git
cd ComfyUI_Dados_Nodes
pip install -r requirements.txt

then restart. Nothing extra to download for this node - stdlib base64 and PIL are all it uses.

Common issues

Honestly, there isn't much to break. If you wire a string into it by mistake it won't accept the connection (it wants IMAGE). If your output string seems suspiciously short, check you didn't feed it a single-frame tensor when you expected a batch - a one-frame input is a one-frame string. Beyond that, it just works, which for a conversion node is the highest compliment available.

CategoryDado's Nodes/Image

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
base64_stringSTRING