Nodes/Quality of Life Nodes for ComfyUI/JSON Image Encoder (Soze)
ComfyUI Node

JSON Image Encoder (Soze)

Image to text — a standalone encoder for JSON payloads

By SozeInc·Created 2 years ago·Updated 8 days ago· 10
JSON Image Encoder (Soze)
  • image
  • encoded
modedata_uri
formatpng
jpeg_quality95
save_path
append_suffixtrue

Sometimes you don't want the key bundled with the image - you just need the encoded image as a bare string you can plug into a value socket, a text file, or any node that eats text. JSON Image Encoder (Soze) is that standalone piece: IMAGE in, one STRING out. No JSON chain involved. It's the same encoding core the chain's Image Pair uses, stripped of the name and chain_in ceremony.

You'll reach for it when the image needs to travel as text but the structure around it is already handled elsewhere - say, feeding an encoded image into a JSON Chain String Pair's value input, or into any API/text node that expects a data URI or file path on its own. It encodes the first frame of the batch; the array variant exists if you need all frames.

How it works

Identical mechanics to the Image Pair's encoder. data_uri mode produces data:image/<fmt>;base64,... (self-contained, but big - a 1MP PNG is ~1.5 MB of base64). filepath mode saves the image to disk and returns the absolute path (tiny, but the output only means something on a machine that can see that file). format picks png/jpeg/webp; jpeg_quality (default 95) only matters for jpeg and webp; save_path and append_suffix control filepath-mode naming, with an extension added automatically if you omit it.

Inputs and outputs

  • image - required IMAGE input (forced). First frame is used.
  • mode - data_uri or filepath.
  • format - png, jpeg, or webp.
  • jpeg_quality, save_path, append_suffix - optional.

Output: encoded, a single STRING - the data URI or the file path.

Installing it

Part of the Soze pack:

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

Restart ComfyUI, or search ComfyUI_Soze in ComfyUI Manager.

Gotchas

The usual suspects: watch payload size in data_uri mode (JPEG + lower quality if the API is strict), and remember it's the first frame only. One pleasant surprise - the decoder exists on the other end, and it's permissive: JSON Image Decoder accepts this encoder's output (data URI or path) as well as URLs, JSON arrays, and newline lists, so an encode→decode round-trip through text is fully supported if you ever need to serialize an image mid-graph.

CategorySoze Nodes/JSON

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
modeCOMBOdata_uri2 options: data_uri, filepath
formatCOMBOpng3 options: png, jpeg, webp
jpeg_qualityoptINT951–100Only used for jpeg / webp.
save_pathoptSTRINGfilepath mode: target path (relative to ComfyUI output dir, or absolute). Extension is added if missing.
append_suffixoptBOOLEANtruefilepath mode: append _00001 if the target already exists.

Outputs (1)

NameTypeDescription
encodedSTRING