Prompt Formatter
Clean up a messy prompt (and A1111-style emphasis) with one click
- STRING
Most prompts you actually work with are not the tidy one-liners from the examples. They're pasted from a Discord message, output by an LLM, or typed at 1am with a space before every parenthesis. DA_PromptFormatter is the janitor: one button that strips the garbage out and hands you back a prompt that ComfyUI will parse the way you meant. It's part of DemonAlone-JS_Addon-ComfyUI, the JS companion pack to the main DemonAlone-nodes repo, and it's inspired by (not a fork of) the "Prompt Formatter (Only Text)" node from younyokel's comfyui_prompt_formatter - same spirit, rewritten.
What it actually fixes
Feed it text and it runs five cleanup passes, all client-side in the browser:
- Collapses runs of spaces down to one.
- Squashes repeated commas and periods (
.,,→.,). - Converts stacked emphasis to weight syntax:
((text))becomes(text:1.21)and[[text]]becomes[text:0.81]. The math is the neat part - each paren multiplies by 1.1, each bracket by 0.9, so((foo))is 1.1² = 1.21. That's the Automatic1111-style prompt you're used to, rewritten in ComfyUI's explicit(text:1.21)dialect. - Deletes spaces hugging brackets:
( girl)→(girl),[boy ]→[boy]. - Inserts a space after a comma or period when it's glued to a letter or number.
There's a Format prompt button on the node and an Undo button, because formatting is destructive and you will occasionally want your raw mess back.
The one input, and the trap hiding in it
The schema is almost insultingly simple: a multiline text input and a single STRING output. But here's the catch that surprises people: the Python node doesn't transform anything. Look at the server side and execute() just passes text straight through. The formatting happens in the browser, and it's applied by rewriting the node's own text widget when you hit Format - so the formatted string is what gets sent on the next queue run.
That means two practical consequences. First, if you run this workflow headless - via the API, in a script, on a machine without a browser open - you get exactly the text you typed in, unformatted. The button is a browser affordance, not a server pipeline. Second, the output is whatever is currently in the widget, so "I clicked Format and the output still looks messy" means you ran before the widget value synced, or you edited after formatting. Format, then queue.
Installing it
Boring and reliable:
cd ComfyUI/custom_nodes
git clone https://github.com/DemonAlone/DemonAlone-JS_Addon-ComfyUI
Or via ComfyUI Manager under "DemonAlone-JS_Addon-ComfyUI". Restart and it shows up under utils/prompt. No models, no dependencies beyond ComfyUI itself.
Where people get burned
Beyond the headless trap, the emphasis conversion is worth a second thought. ((text)) → (text:1.21) changes how your prompt behaves on models trained with different emphasis styles, so if you're hand-tuning weights you may not want every double-paren collapsed. It only touches runs of two or more brackets, so a single (text) is left alone - but know that it's opinionated about your formatting. If you're the kind of person who writes (fancy (word)) intentionally, this node will flatten your intent.
For everyone else - the people pasting garbage from ChatGPT and wondering why the model is confused - it's a genuinely handy five-second fix, and Undo means you can experiment without losing the original.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |