Prompt (comments) π¬
Comment lines out of your ComfyUI prompt without mangling #hashtags
- text
You've got a prompt with three variant endings and you want to try them one at a time. Or you want to leave yourself a note next to a line - "lower the CFG here, it got crispy" - without the encoder solemnly generating the word "CFG". The naive answer is to keep a separate text file and paste back and forth. The better answer is this node: a drop-in prompt editor where lines starting with # or //, trailing #/// notes, and /* ... */ blocks render in red and never reach the encoder.
It's a replacement for the text box on a CLIP Text Encode, not a special pipeline. You type (or paste) your prompt, comment the stuff you're parking, and feed the output text STRING into the positive or negative conditioning via a converted input. Same place a wildcard or an LLM captioner would feed - pure plumbing, no ceremony.
Why the syntax rules exist
This is the part that separates it from a weekend regex. Prompts are full of # and // that mean nothing of the sort - C# minor, #hashtag, https://example.com/pic, ratio 16//9. A naive "delete everything after #" would gut half of them. So the filter has one rule: a marker has to be a word of its own. It only opens a comment when it starts a line or follows whitespace, and # / // also need whitespace after them. a woman, # note is a comment; trending #art and album cover, C# minor are untouched.
/* is exempt from the trailing half of the rule because it carries its own terminator, so /*parked still works - and an unterminated /* comments out everything after it, which is the cleanest way to park the tail of a prompt. Whichever marker comes first wins and runs to its natural end, so a stray /* inside a # note is just text and can't swallow the lines below it.
The filter runs in Python in nodes.py, so the API path behaves exactly like the UI path. The frontend part decorates ComfyUI's own multiline widget rather than replacing it - one textarea, so undo, resizing, and serialization stay core behavior - and paints comments red with an overlay while a live / total line counter sits in the corner. The editor's scanner and the Python filter are line-for-line mirrors of each other (the tests literally extract one from the other's source and diff them against a corpus), so what's painted red is exactly what gets removed.
What you actually set
One input, one output:
text(STRING, multiline) - the prompt. Comment freely; the only widget on the node.textoutput (STRING) - the prompt with comments stripped. Wire it into CLIP Text Encode (right-click the encode's text field β Convert widget to input first) or anywhere else a prompt string is consumed.
There's no toggle for it, but a tidy pass always runs on the way out: doubled commas, space ,, runs of spaces, a trailing comma, and a comma orphaned at the start of a line because the comment above it was removed. Comment-only lines vanish entirely - no empty holes left behind - and blank lines you actually typed collapse to at most one. That's usually what you want. If you need raw filtered text or control over blank lines, that's what the sibling Strip Comments node is for.
The other trick that makes it pleasant: β/ on macOS (Ctrl + / elsewhere) with the cursor in the box. No selection toggles the current line; a selection toggles every line it touches and stays selected so you can press again; indentation survives and native undo works.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/WebCrusader/ComfyUI-PromptComments
Or via ComfyUI Manager, search "ComfyUI-PromptComments". Restart ComfyUI, then hard-refresh the browser (Ctrl+Shift+R / ββ§R) - the frontend lives in a JS file and ComfyUI will happily serve you the cached one. There are no dependencies, no model downloads, no changes to core files; the whole pack is a Python module and one JS file.
Troubleshooting
- Comments aren't red and the shortcut does nothing: you're on the stale JS bundle. Hard-refresh.
- A URL or
#hashtaggot eaten: check the whitespace around the marker.a woman,# noteis not a comment - the marker has to follow whitespace. - A line you expect to be a comment survives: the same rule, mirrored -
#hashtagsurvives by design, and that's the feature, not a bug.
It's a small node that solves a specific, constant annoyance. Once you've written # TODO: swap this line for the portrait variant and watched the encoder ignore it, you won't go back to the text file.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | β |