ComfyUI > Nodes > ComfyUI-LogicUtils > Image to Base64 Encode

ComfyUI Node: Image to Base64 Encode

Class Name

Base64EncodeNode

Category
image
Author
aria1th (Account age: 3016days)
Extension
ComfyUI-LogicUtils
Latest Updated
2026-01-21
Github Stars
0.1K

How to Install ComfyUI-LogicUtils

Install this extension via the ComfyUI Manager by searching for ComfyUI-LogicUtils
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-LogicUtils in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Image to Base64 Encode Description

Converts images to Base64 strings for embedding in HTML/JSON, supporting quality and compression options.

Image to Base64 Encode:

The Base64EncodeNode is designed to convert images into a Base64 encoded string format, which is a widely used method for encoding binary data into a text representation. This node is particularly useful for embedding images directly into HTML or JSON files, where binary data cannot be easily handled. By converting images to Base64, you can ensure that they are easily transferable and compatible with text-based formats. The node provides flexibility in terms of image quality, format, and optional compression, making it a versatile tool for various applications, such as web development, data storage, and transmission.

Image to Base64 Encode Input Parameters:

image

The image parameter is the primary input for the node, representing the image that you wish to encode into a Base64 string. This parameter is required and must be provided in an appropriate image format. The image serves as the source data that will be transformed into a text-based representation, allowing for easier integration into text-based systems.

quality

The quality parameter determines the quality of the image when it is encoded, particularly relevant when the image format is set to JPEG. It is an optional integer parameter with a default value of 100, which represents the highest quality. Lower values will reduce the image quality and file size, which can be beneficial for faster transmission or storage, but may result in a loss of detail.

format

The format parameter specifies the desired output format of the image before encoding it to Base64. It is an optional parameter with options including "PNG", "WEBP", and "JPG", with "PNG" as the default. The choice of format can affect the image's quality, file size, and compatibility with different systems, so selecting the appropriate format is crucial based on your specific needs.

gzip_compress

The gzip_compress parameter is a boolean option that determines whether the image data should be compressed using gzip before being encoded to Base64. This is an optional parameter with a default value of False. Enabling gzip compression can significantly reduce the size of the encoded data, which is advantageous for storage and transmission, but may require additional processing time for compression and decompression.

Image to Base64 Encode Output Parameters:

STRING

The output of the Base64EncodeNode is a STRING that contains the Base64 encoded representation of the input image. This string can be easily embedded into text-based formats such as HTML or JSON, facilitating the integration of images into web pages or data files without the need for separate image files. The encoded string maintains the integrity of the original image data while providing a text-based format that is compatible with a wide range of applications.

Image to Base64 Encode Usage Tips:

  • To optimize the balance between image quality and file size, adjust the quality parameter when using the JPEG format. Lowering the quality can reduce file size but may affect image clarity.
  • Use the gzip_compress option to minimize the size of the encoded data, especially when dealing with large images or when bandwidth is a concern. However, be mindful of the additional processing time required for compression and decompression.

Image to Base64 Encode Common Errors and Solutions:

Invalid image format

  • Explanation: The input image is not in a supported format or is corrupted.
  • Solution: Ensure that the image is in a valid format such as PNG, WEBP, or JPG and is not corrupted before encoding.

Compression error

  • Explanation: An error occurred during the gzip compression process.
  • Solution: Verify that the gzip_compress parameter is set correctly and that there is sufficient memory and processing power to handle the compression task.

Encoding failure

  • Explanation: The node failed to encode the image to Base64 due to an internal error.
  • Solution: Check the input parameters for correctness and try re-running the node. If the issue persists, consult the system logs for more detailed error information.

Image to Base64 Encode Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-LogicUtils
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Image to Base64 Encode