Remove Comments
Strip // and /* */ comments out of prompt text before it hits your encoder
- string
Do you keep prompt files around with notes in them? Things like:
// v2 - added gloves, removing jacket
1girl, black hair, // old: red hair
(detailed eyes:1.2) /* keep */
ComfyUI's text encoder does not care about your annotations - that literal // v2 and /* keep */ goes straight into the conditioning, polluting the prompt. Remove Comments strips them first. It handles line comments (everything from // to end of line) and block comments (everything between /* and */), and both markers are configurable, which is why it's more than a prompt cleaner - it's a general text-scrubber for any tag file or script-like text you're feeding into a workflow.
How it works
The mechanism is plain and it defines the edge cases. The node scans the text, deletes whatever sits between block_comment_start and block_comment_end, then deletes everything from line_comment to the next newline. It is not a tokenizer: nested block comments aren't handled, and if the end marker is missing the block just stays. For prompt text that's perfectly fine; for arbitrary code you'd want something with a real parser.
After comment removal come two optional cleanup passes, and the order matters: newline handling first, then comma normalization.
Inputs and outputs
text(STRING, multiline) - the input to clean.line_comment(STRING, default//),block_comment_start(STRING, default/*),block_comment_end(STRING, default*/) - the markers, all changeable.remove_linefeed-No,All, orBlank Lines Only.Alljoins everything into one line;Blank Lines Onlycollapses empty lines. The blank-line mode is the one you actually want before batching, where a stray newline can turn one prompt into two.normalize_commas(BOOLEAN, default false) - tidy comma spacing: collapses repeated commas, trims space around commas, deletesBREAK,sequences, and drops trailing commas.- Output:
string(STRING) - the cleaned text.
The normalize_commas pass is quietly useful on its own. Tag text that comes out of some tools is littered with BREAK tokens and doubled commas, and this cleans it in one toggle without you touching the comment settings.
Where it fits
A prompt-file pipeline is the natural home: Load Text File → Remove Comments → split into lines → batch. Your source files keep their human-readable notes, and the graph never sees them. Or run it on a blob of tags that needs comma normalization before encoding.
It's pure string manipulation - no model, no dependencies, no Impact Pack. It's also shared machinery: the same normalize_commas routine is reused by the pack's loop node, so if you like what it does here you'll find the identical cleanup in "Replace Variables and Process Wildcard (Loop)".
Installing
Ships with watarika/ComfyUI-Text-Utility. ComfyUI Manager → search "ComfyUI-Text-Utility" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/watarika/ComfyUI-Text-Utility
No pip requirements, no models. If a comment isn't coming out, check the markers: you're probably looking for # comments (Python-style) while the node defaults to // - that's what the marker inputs are for.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — | |
| line_comment | STRING | // | — |
| block_comment_start | STRING | /* | — |
| block_comment_end | STRING | */ | — |
| remove_linefeed | COMBO | 3 options: No, All, Blank Lines Only | |
| normalize_commas | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |