ComfyUI Node

Word Cloud

The ComfyUI_WordCloud generator

By chflame163·Created 3 years ago·Updated about a year ago· 118
Word Cloud
  • color_ref_image
  • mask_image
  • image
  • mask
â—„textâ–º
â—„width512â–º
â—„height512â–º
â—„scale1.00â–º
â—„margin0â–º
◄font_path▾►
â—„min_font_size4â–º
â—„max_font_size128â–º
â—„relative_scaling0.50â–º
◄colormap▾►
â—„background_color#FFFFFFâ–º
â—„transparent_backgroundtrueâ–º
â—„prefer_horizontal0.90â–º
â—„max_words200â–º
â—„repeatfalseâ–º
â—„include_numbersfalseâ–º
â—„random_state-1â–º
â—„stopwordsâ–º
â—„contour_width0.0â–º
â—„contour_color#000000â–º
â—„keynote_wordsâ–º
â—„keynote_weight60â–º

You want a wall of text where the words are sized by how often they show up, layered over an image, with a clean alpha channel so you can composite it - and you want it inside ComfyUI, not in some web tool you have to screenshot. That's this node. The name is not a lie: it's the word_cloud Python library by Andreas Mueller, wrapped into a graph node, plus jieba for splitting Chinese text that has no spaces to split on. Paste in a prompt, a tag list, or a whole transcript and get back a poster-shaped typography image.

It's from chflame163, the same author behind the big LayerStyle and DzNodes pack families. Expect Chinese-first documentation habits and a 😺dzNodes category prefix, but the code itself is a thin, readable wrapper - no model downloads, no network calls, nothing spooky.

Why you'd reach for it

The realistic uses: generate a background of keywords for a thumbnail or title card, make a tag-frequency cloud from a dataset's captions, or drop a word cloud into an img2img pass as a starting image where the text gets interpreted and re-rendered. The MASK output is the underrated part - because the node outputs image and mask, you can composite the cloud over anything with a normal Blender-style mask operation instead of fighting a hard background.

How it works

jieba chops Chinese into words, then WordCloud().process_text() counts frequencies for everything. keynote_words you set get their frequency artificially boosted by keynote_weight (default 60, added on top of the current max), so you can force "BREAKING" or "sale" to dominate without writing it a thousand times. stopwords are dropped - and the node also deletes them from the frequency dict afterward, a deliberate workaround for a quirk in the underlying library.

Layout is standard word_cloud: word size maps to frequency, prefer_horizontal (0.9 default) decides the horizontal/vertical mix, max_words caps the count, and random_state set to -1 means a fresh layout every run while any other number seeds it. Two inputs change the whole output: color_ref_image recolors the text using that image's palette (which overrides colormap), and mask_image turns the cloud into a silhouette - white areas are cut out, and it silently forces the output size to match the mask, ignoring width/height. transparent_background on (default) gives you RGBA plus the mask; turn it off and background_color (#FFFFFF) applies instead.

The inputs that actually matter

  • text - your corpus. Leave it empty and you get a demo string, which is a nice touch.
  • font_path - the dropdown is built from every .ttf/.otf in the directory named in font_dir.ini.
  • mask_image and color_ref_image - the two shortcuts to a shaped, nicely-colored result.
  • stopwords / keynote_words - comma (Chinese or English) or space separated.

Outputs: image (with alpha) and mask, both wired into any preview, Save Image, or compositing setup.

Installing it

ComfyUI Manager finds it by searching "WordCloud" or the author name. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_WordCloud
cd ComfyUI_WordCloud
# on the embedded Python build:
..\..\..\python_embeded\python.exe -m pip install -r requirements.txt

Then restart ComfyUI. The requirements (numpy, pillow, torch, matplotlib, wordcloud, jieba) are all things you almost certainly already have - torch ships with ComfyUI. There are no model files to hunt down; the only asset is the bundled Alibaba-PuHuiTi-Heavy.ttf font.

Troubleshooting

  • CJK text renders as boxes (tofu). The font you picked has no Chinese glyphs. Stick with the bundled Alibaba font, or add a CJK font to your font_dir.
  • On Linux/macOS, only one font shows up. font_dir.ini defaults to C:\Windows\fonts, which doesn't exist off Windows; the plugin falls back to its bundled font. Edit font_dir.ini to point at a real font dir (e.g. /usr/share/fonts) and restart.
  • Old saved workflows. The README's own reminder: after a font change, re-select the font in font_path for nodes saved before the change, or the workflow may load with a stale path.
  • "Why is my size setting ignored?" A connected mask_image owns the dimensions. That's by design.
Category😺dzNodes/WordCloud

Inputs (24)

NameTypeDefaultDescription
textSTRING—
widthINT512—
heightINT512—
scaleFLOAT1.000.1–1000—
marginINT0—
font_pathCOMBO1 options: Alibaba-PuHuiTi-Heavy.ttf
min_font_sizeINT4—
max_font_sizeINT128—
relative_scalingFLOAT0.500.01–1—
colormapCOMBO84 options: viridis, Accent, Blues, BrBG, BuGn, BuPu, +78
background_colorSTRING#FFFFFF—
transparent_backgroundBOOLEANtrue—
prefer_horizontalFLOAT0.900–1—
max_wordsINT200—
repeatBOOLEANfalse—
include_numbersBOOLEANfalse—
random_stateINT-1-1–18446744073709550000—
stopwordsSTRING—
color_ref_imageoptIMAGE—
mask_imageoptIMAGE—
contour_widthoptFLOAT0.00–9999—
contour_coloroptSTRING#000000—
keynote_wordsoptSTRING—
keynote_weightoptINT60—

Outputs (2)

NameTypeDescription
imageIMAGE—
maskMASK—