Nodes/ComfyUI-FLUX-BFL-API/Image to Base64 (BFL)
ComfyUI Node

Image to Base64 (BFL)

IMAGE in, base64 string out

By gelasdev·Created 2 years ago·Updated 25 days ago· 49
Image to Base64 (BFL)
  • image
  • STRING
image_formatjpeg

Every time you use Flux Pro Fill or any image-editing node in this pack, you're secretly relying on this node. The BFL API doesn't accept ComfyUI's IMAGE tensors - it wants pixels as base64 text. Image to Base64 (BFL) is the little converter that bridges the two: you hand it an IMAGE, it hands back a STRING of encoded image data ready to paste into an image or mask input.

It's from gelasdev's ComfyUI-FLUX-BFL-API pack, and it's the only node in the pack that does no network calls and needs no API key. You can use it for anything that wants base64, not just BFL calls - which makes it quietly more useful than its billing suggests.

How it works

Dumb simple, in the best way. The node takes your IMAGE tensor, converts it to a PIL image, encodes it, and base64-encodes the bytes into a string. Two details matter:

  • It converts to RGB first, so don't send it alpha channels expecting them to survive.
  • It operates on image[0] - the first frame only. Feed it a batch and you get just the first image's encoding. That's almost always what you want for a single BFL call.

The inputs that matter

  • image - an IMAGE tensor. Wire it from LoadImage, or from a generation node if you're re-using output.
  • image_format - jpeg (default) or png. This is the choice that actually matters. JPEG is smaller and fine for reference/steering images. PNG is lossless - and it's the one to use for masks, because JPEG compression smears the clean black/white edges your inpaint mask needs. The pack README says exactly this.

Output is a single STRING containing the base64 data.

How it fits a workflow

The canonical setup: LoadImage → Image to Base64 → Flux Pro Fill's image input, and the same for mask (with the format set to png). Or LoadImage → Image to Base64 → any node's image_prompt input, for reference-image steering on the Pro nodes. Since the output is just a string, you can also preview it or pipe it into other tools that consume base64.

Installing

Same pack, same one-liner:

cd ComfyUI/custom_nodes
git clone https://github.com/gelasdev/ComfyUI-FLUX-BFL-API.git
pip install -r requirements.txt

Restart ComfyUI. That's the entire install - this node pulls in nothing beyond torch, and it doesn't need an API key or config at all.

Common issues

Honestly, the failure modes are your own wiring. The most common: forgetting to set png on the mask path and getting a soft-edged mask out of jpeg. The second: expecting a batch to be encoded - only the first image is. And if you've wired it correctly and a downstream node still complains, check that the string isn't being truncated somewhere - base64 output can be long, and a text node that caps length will silently break your pipeline. If a Fill node reports it's "proceeding without mask," the string coming out of this node is the first thing to verify.

CategoryBFL/Utils

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
image_formatoptCOMBOjpeg2 options: jpeg, png

Outputs (1)

NameTypeDescription
STRINGSTRING