ComfyUI Node

Chatbox Overlay

Put words on your generated image without leaving ComfyUI

By Smuzzies·Created 3 years ago·Updated 2 years ago· 22
Chatbox Overlay
  • image
  • IMAGE
textHello
textbox_width200
textbox_height100
max_font_size256
font/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf
alignmentcenter
color#000000
start_x0
start_y0
line_spacing1.5

Chatbox Overlay is the node for when your output isn't finished until there's text on it. Think fake chat-screenshots of AI characters, a line of dialogue under a portrait, character-card art, or a children's-book page where the words have to sit inside the illustration. You drop it between your last image-producing node and SaveImage, type the text, and the node bakes it onto the pixels before anything gets written to disk. That "before the save" placement is the whole point - you end up with a single PNG that already has the caption, no post-editing in GIMP.

It's a one-trick node and proud of it. Where this lives in the ComfyUI world is the deterministic post-processing layer: no model runs, no VRAM touched, just PIL drawing text. That's also why it's such a relief to install - this pack has no requirements.txt at all. It only uses PIL, torch, and numpy, which ComfyUI already ships. No model downloads, no CUDA version roulette, nothing to rot. After the ecosystem doc's parade of "install this, fix the dependency conflict, restart" rituals, this is the rare zero-friction custom node.

How it actually works

Under the hood it's ~70 lines of PIL.ImageDraw. Your IMAGE tensor gets converted to a PIL image, the text is drawn, and the result is converted back to an IMAGE tensor for the save node. The clever bit is the auto-fit loop: it starts the font at your max_font_size and shrinks it one point at a time until the wrapped text fits inside the box you defined. You never hand-tune font size to make text fit - you set the box, and the node negotiates the rest. Word wrapping happens at spaces, which sounds trivial and is genuinely rare among the overlay nodes people actually use.

The inputs that matter

All inputs are required, but you only really touch a handful:

  • text - the words themselves. Multiline, so hit Enter for paragraphs and it's respected.
  • font - a path to a .ttf. The default is a Linux path (/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf). On Windows you must point it at something like c:/windows/fonts/arial.ttf - forward slashes, as the README notes.
  • textbox_width / textbox_height - the box in pixels the text has to fit inside. The sample repo image is a chatbox graphic for 1024x1024 output; size the box to match your bubble.
  • start_x / start_y - where the box's top-left corner sits on the image, in pixels. The README's workflow image is literally a coordinate diagram: calculate these from your image dimensions.
  • max_font_size - the ceiling for the auto-fit (caps at 256). Set it generous; it only shrinks.
  • alignment - left, right, or center, within the box.
  • color - a hex string like #000000. Must be exactly #RRGGBB.
  • line_spacing - float from 1.0 to 2.0 (default 1.5). This is the notable addition over the ancestor pack this was forked from (mikkel/ComfyUI-text-overlay); without it, multi-line text overlaps depending on the font. It's the one input people kept asking for, and it's here.

The single output is IMAGE, which you wire straight into SaveImage or PreviewImage.

Installing it

Two clean paths:

  • ComfyUI Manager - search for "Chatbox Overlay" (or the pack title comfyui_chatbox_overlay) and install, then restart.
  • Manual clone:
cd ComfyUI/custom_nodes
git clone https://github.com/Smuzzies/comfyui_chatbox_overlay

Then restart ComfyUI. The README also notes you can just drop the single chatbox_overlay.py into custom_nodes/ - it genuinely is a one-file node, so that works too.

Where people get burned

  • The font path is the #1 error. Wrong path = the node throws on ImageFont.truetype. Windows users who never change the default get this instantly. Set it once, save your workflow, done.
  • Color parsing is strict. It expects six hex digits after the #. Feed it red or #fff and it crashes.
  • It draws text, not bubbles. The node overlays text only; the chatbox graphic behind it is either in your generated image or the sample included in the repo. The overlay doesn't add a background box.
  • It's dormant. Last commit was early 2025, and the README credits ChatGPT as co-author alongside the upstream pack. Don't expect updates - it's finished, and that's fine.

If your job is just "text on an image, fits, doesn't overlap," this is the smallest thing that does it.

Categoryimage/text

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
textSTRINGHello
textbox_widthINT200
textbox_heightINT100
max_font_sizeINT2561–256
fontSTRING/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf
alignmentCOMBOcenter3 options: left, right, center
colorSTRING#000000
start_xINT0
start_yINT0
line_spacingFLOAT1.51–2

Outputs (1)

NameTypeDescription
IMAGEIMAGE