Nodes/ComfyUI-GadgetNodes/Normalize Prompt
ComfyUI Node

Normalize Prompt

Turn your messy pasted prompt into one clean line

By 2daadv·Created 6 months ago·Updated 21 days ago· 1
Normalize Prompt
    • prompt
    raw_prompt

    You know the feeling. You grab a prompt from a friend's workflow, a Discord paste, or a note file, and it arrives with trailing spaces, stray newlines, a commented-out idea block, and four commas where one would do. ComfyUI will happily encode that garbage, and your tags get muddier for it. Normalize Prompt is the one-trick node that fixes exactly that: messy text in, one clean comma-separated line out.

    It's a single input, single output string cleaner. There's no model involved, nothing to configure, nothing to break. Drop it between whatever generates your prompt and your CLIP Text Encode node and move on.

    What it actually strips

    Reading the source, it does five passes:

    • Comment removal - blocks wrapped in /* ... */ or <!-- ... --> and any # to end of line are deleted. That's how you can leave little notes to yourself inside a prompt and have them vanish before encoding.
    • Whitespace cleanup - leading/trailing spaces per line, then all newlines collapse into a single line with single spaces.
    • Comma normalization - runs of commas with random whitespace become , .
    • Period spacing - puts a space after periods so "a photo.a cat" becomes "a photo. a cat". The exception matters: it skips periods preceded by a digit, so (masterpiece:1.3) and version numbers like SD1.5 survive untouched. That's the detail that keeps the node from mangling weight syntax.
    • Edge trimming - leading and trailing commas get cut.

    The output is a prompt string you can feed straight into a CLIP Text Encode, or chain into this pack's Split Prompt if you use that -(tag) negative syntax.

    Inputs and outputs

    Inputs: just raw_prompt - a string, wired from a text node or typed in. Outputs: prompt. That's the whole surface. The one behavior worth knowing: if the input is empty or whitespace, it passes through unchanged instead of erroring, which makes it safe to stick in a batch workflow where some prompts may be blank.

    Install

    Same as any node in this pack - ComfyUI Manager (search "ComfyUI-GadgetNodes") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/2daadv/ComfyUI-GadgetNodes.git
    pip install -r ComfyUI-GadgetNodes/requirements.txt
    

    Restart and it shows up under Gadget/prompt. No extra dependencies, no models. It's also one of the few nodes in the pack that the README flags as safe on the Nodes 2.0 frontend, since it's pure Python with no UI tricks.

    The one gotcha

    It's a lossy cleaner, and the loss is #. If you ever write a prompt that legitimately contains a # - some LoRA activation triggers or style tokens use them - a #... to end-of-line will be eaten. That's rare in practice, but if a tag mysteriously disappears after you add this node, that's the culprit. Everything else it touches is pretty universally safe to clean.

    There's nothing glamorous here, and that's the point. In a world where prompting is half the battle, a node that guarantees your tag list is whitespace-stable and comment-free before the encoder sees it is quietly worth having in every prompt chain.

    CategoryGadget/prompt

    Inputs (1)

    NameTypeDefaultDescription
    raw_promptSTRING

    Outputs (1)

    NameTypeDescription
    promptSTRING