Nodes/Comfyroll Studio/πŸ”€ CR Text Length
ComfyUI Node Runs on cloud

πŸ”€ CR Text Length

Count the characters in a string

By Suzie1Β·Created 3 years agoΒ·Updated 2 years agoΒ· 1,287
πŸ”€ CR Text Length
    • INT
    • show_help
    β—„textβ–Ί

    About as simple as Comfyroll gets: feed it a string, get back its character count as an integer. No parsing, no options - the whole job is len(text).

    Why you'd actually use this

    On its own, "how long is this string" isn't a very exciting question. It gets useful when you wire the output into something that makes a decision based on it. A couple of real shapes this takes: checking whether a text field is empty (length 0) before letting a branch of your graph run, feeding a length-based condition into a comparison or gate node elsewhere in Comfyroll's utility set, or just sanity-checking that a prompt assembled from several concatenated pieces (CR Text Concatenate, CR Split String outputs, and the like) came out the size you expected - a suspiciously short or long number is a fast way to notice a wiring mistake before you burn a generation on it.

    One thing worth being precise about: this counts characters, not tokens. If you're trying to gauge whether a prompt is going to get truncated by CLIP's roughly 75-77 token limit, character count is a rough proxy at best - tokenization doesn't map 1:1 to characters (whitespace, punctuation, and how words split into subword tokens all affect the real count). Useful for "is this field empty" or "did my concatenation work," not a reliable token budget check.

    The inputs and outputs that matter

    • text - the string to measure. That's the entire input.

    Output: a single INT (the character count), plus the standard show_help link.

    How to install it

    ComfyUI Manager - search "Comfyroll Studio", install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes.git
    

    then restart. No models, no dependencies.

    Common issues

    There's genuinely very little that can go wrong with this node in isolation - it can't error on valid text input, and an empty string just returns 0. The gotcha, if there is one, is upstream of it: if you're checking this length to catch an "empty" field and it's coming back nonzero when you expect zero, check for stray whitespace passed through from an earlier node (a common byproduct of a naive string split elsewhere in the pack) - a string containing just a space isn't empty as far as len() is concerned.

    If the node doesn't appear in your search at all, that's the pack failing to load as a whole, not this node specifically - check your ComfyUI console for Comfyroll Studio: Failed to load ... nodes, commonly a Pillow version conflict from another installed custom node, and reinstall Pillow (pip install --upgrade --force-reinstall pillow) or update Comfyroll through Manager.

    Category🧩 Comfyroll Studio/πŸ› οΈ Utils/πŸ”€ Text

    Inputs (1)

    NameTypeDefaultDescription
    textSTRINGβ€”

    Outputs (2)

    NameTypeDescription
    INTINTβ€”
    show_helpSTRINGβ€”