Nodes/ComfyUI_Anytext/AnyText Encoder
ComfyUI Node

AnyText Encoder

Turn text + a position mask into AnyText conditioning

By zmwv823·Created 2 years ago·Updated about a year ago· 103
AnyText Encoder
  • model
  • mask
  • texts
  • latent
  • image
  • fonts
  • positive
  • negative
  • font_hint
  • font
prompt
font_nameAnyText-Arial-Unicode.ttf
modetrue
sort_radiotrue
a_promptbest quality, extremely detailed,4k, HD, supper legible text, clear text edges, clear strokes, neat writing, no watermarks
n_promptlow-res, bad anatomy, extra digit, fewer digits, cropped, worst quality, low quality, watermark, unreadable text, messy words, distorted text, disorganized writing, advertising picture
random_maskfalse
revise_posfalse
font_applytrue
show_glyphfalse

This is the brain of the AnyText workflow. SD 1.5 famously can't spell - the KB puts it flatly: "SD 1.5 cannot reliably generate legible text in images." AnyText's whole trick is to stop asking the diffusion model to imagine letters and instead hand it the exact glyphs, rendered as a hint image, plus where on the canvas they go. UL_AnyTextEncoder is the node that builds that hint and packs it into conditioning the AnyText sampler can actually use.

So you don't type "a sign that says 开门" and pray. You give this node the words, a mask marking where each word lands, and it does the glyph rendering and OCR-style stroke encoding that AnyText was trained on. That's why it works in Chinese, Japanese, Korean and English when a raw SD 1.5 checkpoint would produce alphabet soup.

How it works

AnyText splits the job in two: an auxiliary latent module that consumes glyph shapes, positions and a masked image, and a text-embedding module that encodes the stroke data. UL_AnyTextEncoder sits on the input side of that. It takes your AnyText_Model, a mask telling it which regions are text, a prompt for the scene, and texts - the actual strings, as a LIST (that's what UL_AnyTextFormatter produces). It renders those strings into a glyph hint using font_name, blends in your quality prompts, and emits conditioning. Feed an image on the optional input and you're in edit mode - changing text that's already in a picture rather than generating fresh.

The inputs and outputs that matter

  • mask (MASK) and texts (LIST) - the two that carry the actual work. The mask says where, the texts say what. Get these wrong and everything downstream is noise. texts almost always comes from UL_AnyTextFormatter.
  • prompt - the scene description (not the text itself; that lives in texts).
  • font_name - the base font used to draw the glyph hint. AnyText's canonical one is Arial_Unicode.ttf. On a fresh install this dropdown shows Auto_DownLoad, which pulls it from HuggingFace on first run.
  • mode (generate vs edit), random_mask and revise_pos are behavior toggles; leave them at defaults until you have a reason.
  • Optional image switches on text editing; optional fonts / show_glyph let you inspect what got rendered.

Outputs are positive and negative CONDITIONING - wire both straight into UL_AnyTextSampler - plus font_hint and font IMAGE outputs so you can preview the glyph layout before you burn a sampling pass on it. That preview is worth checking every time; if the hint looks wrong, the render will too.

How to install it

ComfyUI Manager, search ComfyUI_Anytext and install, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/zmwv823/ComfyUI_Anytext

then restart. The heavy lift isn't the node, it's the models: you need an AnyText checkpoint (or an SD 1.5 checkpoint plus the AnyText control model) loaded through one of the AnyText loaders, and a base font in ComfyUI/models/fonts - Arial_Unicode.ttf is the one the paper ships with. The Auto_DownLoad font option grabs it from HuggingFace, so a machine with no HF access needs the file placed manually.

Common issues & troubleshooting

"Font not found" or blank glyphs. The base font has to exist in models/fonts. If auto-download can't reach HuggingFace (locked-down cloud runner, offline box), drop Arial_Unicode.ttf in there yourself.

The text lands in the wrong place, or overlaps. That's the mask, not the model. Each string in texts maps to a region in mask; if the count or order is off, positions scramble. Preview font_hint and fix the mask before blaming the sampler.

You expected English text and could've used Flux. Be honest about why you're here. In 2026, Flux, Qwen-Image and Ideogram render English straight from the prompt. AnyText is a pre-Flux, SD 1.5-era tool - reach for it for multilingual CJK text or for editing text in an existing image, which the edit models still don't do cleanly. For a poster in English, this is the hard way.

Reception was always mixed. When AnyText dropped, the community reaction ran from "this looks amazing" to a blunt "it doesn't really work." Treat it as a specialist with a fiddly setup, not a magic text button, and your expectations will survive contact.

CategoryUL Group/Image Generation

Inputs (16)

NameTypeDefaultDescription
modelAnyText_Model
maskMASK
promptSTRING
textsLIST
latentLATENT
font_nameCOMBOAnyText-Arial-Unicode.ttf1 options: Auto_DownLoad
modeBOOLEANtrue
sort_radioBOOLEANtrueOrder of draw texts according to mask position orders. ↕ for y axis. It will draw text-content(“string”) from start-to-end(order) on the mask position from top to bottom. ↔ for x axis .It will draw text-content(“string”) from start-to-end(order) on the mask position from left to right. 根据遮罩位置顺序决定生成文本的顺序。
a_promptSTRINGbest quality, extremely detailed,4k, HD, supper legible text, clear text edges, clear strokes, neat writing, no watermarks
n_promptSTRINGlow-res, bad anatomy, extra digit, fewer digits, cropped, worst quality, low quality, watermark, unreadable text, messy words, distorted text, disorganized writing, advertising picture
random_maskBOOLEANfalseRandom generate mask, the input mask will be ignored. 随机生成遮罩,输入的遮罩将被忽略。
revise_posBOOLEANfalseWhich uses the bounding box of the rendered text as the revised position. However, it is occasionally found that the creativity of the generated text is slightly lower using this method, It dosen’t work in text-edit mode. 使用边界盒子渲染文字作位置调整。但是发现偶尔会影响生成质量,仅在使用随机生成遮罩时生效。
imageoptIMAGE
fontsoptANYTEXT_FONTS
font_applyoptBOOLEANtrue
show_glyphoptBOOLEANfalse

Outputs (4)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING
font_hintIMAGE
fontIMAGE