Nodes/KJNodes for ComfyUI/Create Text Mask
ComfyUI Node Runs on cloud

Create Text Mask

Rendering (and animating) text as a mask

By kijai·Created 3 years ago·Updated 3 days ago· 3,123
Create Text Mask
    • IMAGE
    • MASK
    invertfalse
    frames1
    text_x0
    text_y0
    font_size32
    font_colorwhite
    textHELLO!
    font
    width512
    height512
    start_rotation0
    end_rotation0

    Create Text Mask does exactly what it says: it renders a string of text at a fixed position on a canvas and gives you back both an image and a mask shaped like that text. Where Create Text On Path moves text along a coordinate list, this one is simpler and more direct - one text block, one position, and an optional rotation animation if you want it moving.

    Why you'd want this

    Text-shaped masks are useful anywhere you want to place or reveal content in the exact shape of a word - inpainting a caption into a scene, generating a watermark region, driving a "text reveal" transition where an image appears through the letters, or building a rotating title-card animation for a video intro. Because you get both the raw rendered image and a mask, you can use it purely as a mask (feeding a downstream inpaint or compositing step) or as visible text content on its own.

    The rotation feature is the thing that separates this from a plain "draw text" utility: set start_rotation and end_rotation to different values and the node interpolates between them across your requested frame count, giving you a spinning-text animation without any extra nodes.

    How it works

    The text is rendered at (text_x, text_y) on a canvas of width × height, using whatever font and size you pick. If start_rotation and end_rotation match, you get frames copies of the same static text image. If they differ, the node interpolates the rotation angle linearly across the requested frame count, so frame 1 starts at start_rotation and the last frame lands at end_rotation.

    One detail worth knowing up front: the node looks for fonts specifically in ComfyUI/custom_nodes/ComfyUI-KJNodes/fonts - that's straight from the node's own description, not a guess, and it's the first place to check if a font you expect isn't showing up.

    The inputs and outputs that matter

    • text (multiline, default "HELLO!") and font (an enum of what the node finds in that fonts folder - expect choices like FreeMono.ttf or a bold display face).
    • text_x / text_y - placement on the canvas (both default 0, meaning top-left corner - you'll usually want to set these).
    • font_size (default 32) and font_color.
    • width / height - canvas size, default 512×512.
    • frames (default 1) - how many frames to render; only matters if you're animating rotation.
    • start_rotation (0–359, default 0) and end_rotation (-359–359, default 0) - set these apart to get a rotation animation across frames.
    • invert (boolean) - flips the mask polarity.

    Two outputs: IMAGE (the rendered text) and MASK (the text shape as a mask).

    How to install it

    • ComfyUI Manager - search KJNodes for ComfyUI, install, restart.
    • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt (portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart.

    No model downloads - plain text rendering, no ML.

    Common issues & troubleshooting

    Custom font doesn't appear in the dropdown. This is the one real gotcha with this node: fonts have to live in ComfyUI/custom_nodes/ComfyUI-KJNodes/fonts specifically, not just anywhere on your system. Drop your .ttf/.otf file in there and restart ComfyUI if it's not showing up.

    Text is cut off or lands off-canvas. text_x/text_y default to 0,0, which is the corner, not centered - combined with a large font_size, that can push text partly or fully off the visible canvas. Reposition and check width/height are large enough for what you typed.

    Rotation animation looks like nothing's happening. Make sure frames is set higher than 1 - with frames at the default of 1, start_rotation and end_rotation have nothing to interpolate across, so you'll only ever see the starting angle.

    CategoryKJNodes/text

    Inputs (12)

    NameTypeDefaultDescription
    invertBOOLEANfalse
    framesINT11–4096
    text_xINT00–4096
    text_yINT00–4096
    font_sizeINT328–4096
    font_colorSTRINGwhite
    textSTRINGHELLO!
    fontCOMBO3 options: FreeMono.ttf, FreeMonoBoldOblique.otf, TTNorms-Black.otf
    widthINT51216–4096
    heightINT51216–4096
    start_rotationINT00–359
    end_rotationINT0-359–359

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK