Nodes/ComfyUI-Info-Prompt-Toolkit/Remove Prompt Comments
ComfyUI Node

Remove Prompt Comments

Strip // notes from a prompt without breaking the text

By kinorax·Created 5 months ago·Updated about a month ago· 2
Remove Prompt Comments
    • string
    string

    ComfyUI has a quiet convention: lines in a prompt starting with // are comments. The sampler ignores them, but they stay visible in the text box, which makes them perfect for leaving yourself notes - "// face fix applied here", "// try swapping this LoRA". The catch is that other consumers of that text don't know the convention. Feed a commented prompt into a caption file, a tagger, or anything that treats text literally, and your // notes become part of the data. Remove Prompt Comments exists to clean that up: it strips // line comments and /* ... */ block comments from a string, and hands you the tidy version.

    It's a pure text utility - no model, no VRAM - and it belongs to the pack's prompt/caption toolchain, sitting naturally next to Combine Prompts and the caption-token nodes.

    How it works

    Give it a string and it removes two comment forms:

    • // - everything from // to the end of that line.
    • /* ... */ - block comments spanning any number of lines.

    The result comes out on the single string output. It's exactly the same comment handling the pack's Prompt Template node applies internally, exposed as a standalone step - so if you've used that node's behavior and wanted it as a separate stage, here it is.

    One thing it does not do: it won't touch prompt emphasis syntax, weights, or wildcard tokens. It's surgical about comments only, which is the right scope - you want the rest of your prompt left alone.

    When you'd reach for it

    Three concrete situations, roughly in order of how often they come up:

    1. Caption files. Training captions (kohya-style <stem>.txt next to each image) should be clean text - // notes baked into a caption confuse the training run and pollute your dataset. If you keep commented prompts in your graph, run them through this node before writing captions with Caption File Saver or the pack's image saver.

    2. Sharing text. Any time you copy a prompt out of ComfyUI into a post, a comment, or another tool, the // lines go with it. A quick pass through this node makes the copy look like it was hand-written.

    3. Sanitizing before tagging/re-encoding. If you pipe a prompt into a text encoder, a tagger, or an LLM-based captioner, this node guarantees no note text leaks into the result.

    The string input is optional and force-input, so you can wire it inline in a chain: tagger output → Combine PromptsRemove Prompt Comments → text encoder.

    The honest caveat

    It's a small node and there's a real chance you never need it - stock ComfyUI prompt text rarely carries comments unless you adopt the convention yourself. But it's also the difference between "my prompt is a readable document with notes" and "my prompt is a readable document with notes that silently corrupt downstream output." If you comment your prompts (and you should - it's one of the few documentation tools the graph gives you), you want this node at the boundary where that text leaves the prompt world.

    Installing

    Part of kinorax/comfyui-info-prompt-toolkit:

    cd ComfyUI/custom_nodes
    git clone https://github.com/kinorax/comfyui-info-prompt-toolkit.git
    cd comfyui-info-prompt-toolkit
    pip install -r requirements.txt
    

    or install "Info-Prompt-Toolkit" via ComfyUI Manager, then restart. No model files, no dependencies beyond base ComfyUI - the lowest-risk kind of node to add.

    CategoryInfo-Prompt-Toolkit/Prompt

    Inputs (1)

    NameTypeDefaultDescription
    stringoptSTRINGPrompt text to remove // and /* */ comments

    Outputs (1)

    NameTypeDescription
    stringSTRING