ComfyUI Extension: Comfy Text Stats

Authored by scofano

Created

Updated

0 stars

Node: Text Stats (Char & Word Count). A lightweight ComfyUI custom node that takes a text string and outputs character and word counts (INT). Ideal for caption preprocessing, prompt analytics, and dataset workflows.

Custom Nodes (0)

    README

    ๐Ÿงฉ Comfy Text Stats (Char & Word Count)

    A lightweight ComfyUI custom node that receives a text string and outputs:

    • ๐Ÿงฎ Character count (INT)
    • โœ๏ธ Word count (INT)

    This node is designed for text preprocessing, caption analytics, or quick statistics inside your ComfyUI workflows.


    ๐Ÿš€ Features

    โœ… Simple and fast โ€” no dependencies
    โœ… Unicode-aware word detection (supports multilingual text)
    โœ… Deterministic results (not affected by seeds)
    โœ… Works with any STRING input from other nodes

    <p align="center"> <img src="https://raw.githubusercontent.com/scofano/comfy-text-stats/main/text_stats.png" alt="Text stats" style="width: 100%; height: auto;"> </p>

    ๐Ÿ“ฆ Installation

    Option 1 โ€” Via ComfyUI-Manager (recommended)

    1. Download comfy-text-stats.zip
    2. In ComfyUI-Manager, go to:
      Install โ†’ Install from ZIP
    3. Select the ZIP file and click Install
    4. Then Reload Custom Nodes (or restart ComfyUI)

    Option 2 โ€” Manual Install

    1. Extract the folder to your ComfyUI custom node directory:
      ComfyUI/
      โ””โ”€โ”€ custom_nodes/
          โ””โ”€โ”€ comfy-text-stats/
              โ”œโ”€โ”€ __init__.py
              โ”œโ”€โ”€ text_stats.py
              โ”œโ”€โ”€ README.md
              โ””โ”€โ”€ requirements.txt
      
    2. Restart ComfyUI.

    ๐Ÿง  Usage

    Node name

    Text Stats (Char & Word Count)
    Category: Text / Utils

    Inputs

    | Name | Type | Description | |------|------|--------------| | text | STRING | The text input to analyze. Supports multiline input. |

    Outputs

    | Name | Type | Description | |------|------|--------------| | char_count | INT | Number of characters (including spaces, punctuation, and newlines). | | word_count | INT | Number of words (using Unicode-aware regex). |


    ๐Ÿงช Example

    Input text:

    ComfyUI makes custom nodes easy!
    

    Outputs:

    char_count = 33
    word_count = 5
    

    ๐Ÿ”ง Technical Details

    • Word detection uses the regex:
      \b\w+\b
      
      which matches Unicode word boundaries.
    • The node is deterministic (IS_CHANGED checks text length for caching).

    ๐Ÿ’ก Use Cases

    • Text preprocessing for captioning or prompt tuning
    • Generating text metadata before feeding into LLM pipelines
    • Measuring caption sizes in dataset workflows

    ๐Ÿ“„ License

    MIT License ยฉ 2025 โ€” freely usable and modifiable.
    Contributions welcome!