Nodes/ComfyUI-Draggable-Prompt-Sorter/Draggable Prompt Sorter
ComfyUI Node

Draggable Prompt Sorter

Stop retyping your prompt to reorder tags — drag them instead

By matsukasa·Created 3 months ago·Updated 19 days ago· 0
Draggable Prompt Sorter
  • text
  • prompt
order_state

You know the ritual. You're tuning a tag-based model - Illustrious, NoobAI, Pony V6, any of the SDXL lineage where comma-separated booru tags are still the whole game - and you want to test whether 1girl reads better before solo or after it. In ComfyUI that means opening the CLIP Text Encode box and retyping the entire string, one tag at a time, hoping you don't fat-finger a comma. Every A/B test is a fresh chance to break your prompt.

Draggable Prompt Sorter is the anti-ritual: it takes a comma-separated prompt string from an upstream node and turns each item into its own draggable, clickable button on the node's face. Drag buttons to reorder them, click to toggle a tag off, and the node hands the surviving items downstream in whatever order you arranged. No retyping, no text surgery. For a tiny utility it's a surprisingly big quality-of-life win if you spend your evenings shuffling tags.

What it actually does

The backend is almost embarrassingly small: it splits your text on commas, strips whitespace, and joins the enabled items back with ", ". That's it - no weights, no model, no API. The clever part is all in the frontend JavaScript, which draws the buttons and then writes your arrangement into a hidden order_state widget.

That widget is the secret sauce. When you reorder or toggle, the JS serializes the whole button list - text and on/off state - into JSON and stashes it in order_state, which gets saved inside your workflow file. Reopen the workflow tomorrow, hit Queue, and your exact ordering is still there. This is the same "workflow is JSON, state lives in the graph" trick that makes ComfyUI workflows reproducible, applied to your prompt editing session.

Two inputs, one output:

  • text - any STRING/TEXT-style output from an upstream node. It's hidden on the node and forceInput, so it has to come from a wire, not a typed box. A primitive string node, another sorter, a LoRA-stacking tool that emits a built prompt - whatever.
  • order_state - the hidden JSON widget. You never touch it; it's how the frontend persists your layout.
  • prompt (STRING) - the reordered, filtered prompt. Wire it into a CLIP Text Encode (convert its text widget to input first), or anywhere else a string flows.

The one button you need: Update

Here's the part that surprises people. Because your text comes from upstream, the node can't know what tags you'll get until something runs. So the author gave the node an Update button sitting right under the title bar. Pressing it executes the workflow only up to this node - ComfyUI's partial-run feature, app.queuePrompt scoped to this node's id - fetches the fresh text, and repaints the buttons. No full generation, no burning your GPU to refresh a tag list. When you're actually happy and hit Queue for real, the whole graph runs and your arrangement flows downstream.

Installing it

This is the friendliest part. The pack is on the Comfy Registry and has zero Python dependencies - no requirements.txt to fight, no model downloads. Easiest path:

  1. In ComfyUI Manager, open Custom Nodes Manager.
  2. Search "Draggable Prompt Sorter" and hit Install.
  3. Restart ComfyUI and reload the browser.

Or the manual route:

cd ComfyUI\custom_nodes
git clone https://github.com/matsukasa/ComfyUI-Draggable-Prompt-Sorter.git

Then restart ComfyUI and reload the browser - the UI is all frontend JS, so if the buttons don't appear, a hard refresh (Ctrl+Shift+R) fixes cache issues. Update later with git pull --ff-only.

Where people get burned

  • No auto-resize. Add a long prompt and the node doesn't grow to fit - long tags wrap inside the buttons, and the button area scrolls vertically. There's a drag handle (the ... row at the bottom) to set how tall the button area is, and it remembers your size.
  • Your arrangement resets when the tags change. Saved order only sticks if the incoming text contains exactly the same items. Add a tag, remove one, and everything snaps back to input order, all enabled. That's by design, but it'll catch you mid-workflow.
  • Update won't un-toggle. It refreshes the upstream text but leaves disabled buttons disabled. If a tag disappears upstream, you'll have to re-enable it by hand.
  • Duplicates are separate buttons. masterpiece, masterpiece gives you two independent buttons, which is what you want if you're A/B testing - just don't expect them to merge.

For a one-function node it's shockingly well made, and for tag-model prompting it's the only drag-and-drop prompt editor I've found that doesn't come with a dozen extra features I have to disable.

Categoryprompt

Inputs (2)

NameTypeDefaultDescription
text*
order_stateSTRING

Outputs (1)

NameTypeDescription
promptSTRING