ComfyUI Node

Clean Prompt(XTNodes)

Dedupe and tidy a prompt string, especially one built from trigger words

By X-T-E-R·Created 2 years ago·Updated 2 years ago· 50
Clean Prompt(XTNodes)
  • prompt
  • result
remove_duplicatestrue
whitespace_stylekeep

This one isn't a loader - it's the pack's cleanup utility, and the reason it exists becomes obvious the moment you've wired a civitai_trigger_words output from one of this pack's loaders into your prompt. Those lists get messy fast, especially once you're stacking three or four LoRAs and each one hands back its own comma-pile of trigger words, some overlapping, some with stray whitespace. Clean Prompt takes whatever you feed it, splits it on commas, strips the junk, and optionally kills duplicates.

How it works

The prompt input is typed as a ComfyUI wildcard (*), so it'll accept a plain STRING, a LIST like civitai_trigger_words, or honestly whatever else you wire into it - internally it converts anything non-string to a comma-joined string first. From there it splits on commas, trims whitespace off every piece, and drops anything that ends up empty. If remove_duplicates is on (the default) it also drops repeats, comparing entries after stripping out everything except letters, digits, spaces and underscores - so "blue sky" and "blue sky!" collide as the same tag, but "Blue Sky" and "blue sky" don't, since the comparison is case-sensitive. whitespace_style then optionally normalizes every remaining tag to use spaces or underscores consistently - handy if you're mixing trigger words pulled from Civitai (which tend to use spaces) with tags typed by hand in underscore style, or the reverse.

The inputs and outputs that matter

  • remove_duplicates (BOOLEAN, default true) - turn it off if you actually want exact repeats preserved, say to weight a tag by mentioning it twice.
  • whitespace_style (enum: keep / space / underscore, default keep) - leave it on keep to change nothing about spacing, or pick a direction to normalize.
  • prompt (optional, wildcard type) - the thing being cleaned; anything left unconnected returns an empty result rather than erroring.

Output is a single result STRING, ready to wire into a CLIP Text Encode node or into further concatenation.

How to install it

Same pack, same one-time step - ComfyUI Manager, search "ComfyUI Easy Civitai (XTNodes)", or clone plus pip install -r requirements.txt, then restart. Worth knowing: this node has essentially no dependency footprint of its own - it doesn't touch blake3, dynaconf, or the Civitai API at all, which is exactly why it's one of the nodes that survives even when this pack's loaders don't.

Common issues & troubleshooting

If you installed this pack expecting the checkpoint and LoRA loaders too, and only this node (plus its sibling, Prompt Concatenate) turned up, that's a real, reported failure - two open GitHub issues describe precisely that, one asking outright if the project's been abandoned. The loader nodes live in separate files that import the pack's Civitai-lookup machinery and its five pip dependencies, and this pack's __init__.py swallows any import error from those files without printing anything. A failed blake3 build, say, takes out every loader silently while leaving this node untouched, since it has nothing to fail on. If that's your situation, re-run pip install -r requirements.txt inside ComfyUI's actual Python environment and read the terminal output line by line rather than trusting it finished cleanly - that's the only way this pack will tell you what actually broke.

CategoryXTNodes/prompt

Inputs (3)

NameTypeDefaultDescription
remove_duplicatesBOOLEANtrue
whitespace_styleCOMBOkeep3 options: keep, space, underscore
promptopt*

Outputs (1)

NameTypeDescription
resultSTRING