ComfyUI Extension: ComfyUI Text Processor
An advanced text processing node for ComfyUI.
Custom Nodes (0)
README
ComfyUI Text Processor
A comprehensive suite of utility nodes for ComfyUI: Text Processing, Logic Evaluation, and Image Tools. Designed to enhance prompt engineering and streamline automated workflows.
1. Advanced Text Filter Node (Core)
This is a powerful and flexible text processing node for ComfyUI, designed to automate and simplify your dynamic prompt workflows.
Whether you need to precisely extract sections from a large text block, batch replace keywords, or clean up messy text, this node provides robust support. Its dual-output design allows you to create complex node chaining, passing the remaining text from one node to the next for further processing.
Core Features
- Dual Outputs (Node Chaining): Provides
processed_text (Target)andremaining_textoutputs. You can chain theremaining_textto anotherAdvancedTextFilternode for multi-step text parsing. - 13+ Operation Modes:
- Global Find/Replace/Extract
- First-Match Split/Between
- Format Cleanup
- Powerful Regex Support: A
use_regextoggle switches all find and split operations to use Regular Expressions for complex pattern matching. - Multi-Keyword Handling:
Find/Replaceoperations support multiple, comma-separated (,) targets in theoptional_text_inputfield. - Input Flexibility: An optional
external_textinput allows you to concatenate two text sources (like B-box data and a prompt) before processing. - Pre-processing: Built-in
to UPPERCASE/to lowercasefunctions to normalize case before any operation.
Operation modes
The node's operations are split into three main categories:
A. Find / Replace / Extract (Global Operations)
This group finds and processes all matching instances. It uses the optional_text_input field as the target.
find and remove: Removes all specified keywords.find and replace: Replaces all keywords withreplace_with_text.find all (extract): Extracts all matched keywords; returns original text with matches removed as "remaining".
B. Split & Between (First Match Only)
This group targets only the first matched instance. It uses the start_text and end_text fields.
extract between/remove betweenextract before start text/remove after start textextract after start text/remove before start text
C. Text Cleanup
remove empty lines,remove newlines,strip lines (trim),remove all whitespace.
2. Text Utilities
Text Input Node
A smart text combiner that merges up to 7 text sources into a single string.
- Flexible Inputs: Mix of 3 input slots (for chaining) and 4 text widgets (for manual input).
- Auto-Cleaning: Automatically filters out empty inputs to prevent double separators.
- Fun Fallback: If no input is provided, it returns a cute placeholder prompt.
Text Scraper Node
Fetches and formats headlines from any URL. Ideal for injecting real-time context into LLMs.
- Simple Interface: Just input a URL string.
- Smart Parsing: Uses heuristics to identify headlines (
h1-h4, class names). - Safe: Includes timeouts and error handling to prevent workflow freezing.
Text Storage Node
A persistent "clipboard" for ComfyUI. Save, load, and manage text snippets directly within the interface.
- Modes:
Save,Load,Remove,Replace. - Local Storage: Saves data to
text_storage.jsoninside the node folder (easy backup). - Auto-Refresh: Automatically updates the dropdown list when new text is saved.
Wildcards Node (Basic & Advanced)
Generate dynamic prompts using wildcard syntax (e.g., __style__) and random choices (e.g., {cat|dog}).
- Two Versions:
- Basic: Simple text box interface, compact.
- Advanced: Adds dropdown menus to select wildcard files directly from your
wildcardsfolder.
- Cross-Platform: Fully supports Windows and Linux/macOS paths.
- Independent Seeds: Each input field uses a unique random seed offset to ensure variety.
3. Logic & Math Nodes (Simple Eval)
Safely evaluate Python expressions for dynamic calculations and logic flow. Powered by simpleeval.
Simple Eval (Integers / Floats / Strings)
Perform mathematical calculations or string manipulations without writing complex code.
- 3 Variants: Dedicated nodes for
Integers,Floats, andStrings. - Variables: Supports inputs
a,b, andc. You can use them in your expression (e.g.,(a + b) * 2ora + " " + b). - Safe execution: Restricted environment prevents unsafe code execution while allowing powerful logic.
- Console Logging: Optional toggle to print results to the console for debugging.
4. Image Utilities
Image Cropper
A handy utility to crop images directly within your workflow.
- Targeted Cropping: Easily remove unwanted borders or focus on specific subjects.
- Batch Processing: Supports cropping for image batches.
名クAdd Text to Image
Renders text onto images with advanced formatting options.
- Auto-Scaling: Text size automatically adjusts to fit the image width.
- Background Box: Supports semi-transparent background colors with padding.
- Batch Support: Can process image batches; text labels loop automatically if fewer than images.
- Compatibility: Outputs standard RGB images to ensure compatibility with Video/VAE nodes.
Installation
Method 1: Via ComfyUI Manager (Recommended)
This is the easiest way to install the node pack.
- Open ComfyUI Manager within your ComfyUI interface.
- Click on "Custom Nodes Manager".
- Search for
ComfyUI Text Processor. - Click Install and wait for the process to complete.
- Restart ComfyUI.
Method 2: Manual Installation
If you prefer terminal commands or don't use the Manager:
- Navigate to your custom nodes directory:
cd ComfyUI/custom_nodes/ - Clone this repository:
git clone [https://github.com/rookiestar28/ComfyUI_Text_Processor.git](https://github.com/rookiestar28/ComfyUI_Text_Processor.git) - Install dependencies:
pip install -r requirements.txt - Restart ComfyUI.
Asset Setup (Optional)
- Fonts: Place your
.ttfor.otffiles inComfyUI/custom_nodes/ComfyUI_Text_Processor/fonts/for the Add Text to Image node. - Wildcards: Place your wildcard text files in
ComfyUI/wildcards/orComfyUI/custom_nodes/ComfyUI_Text_Processor/wildcards/.