Nodes/ComfyUI-MoonNodes/πŸŒ— Moon Indexed Encoder
ComfyUI Node

πŸŒ— Moon Indexed Encoder

One text box, many region prompts, zero spaghetti

By m0rtus59Β·Created 3 months agoΒ·Updated 9 days agoΒ· 8
πŸŒ— Moon Indexed Encoder
  • clip
  • CONDITIONING
β—„textβ–Ί
β—„greedyfalseβ–Ί

Regional prompting normally means one CLIP encode node per region, and the graph balloons into exactly the "unreadable bowl of noodle spaghetti" the MoonNodes README says it's trying to prevent. MoonIndexedEncoder collapses all of that into a single text box: you write one prompt per area, separated by the keyword BREAK, and it spits out a whole list of conditionings.

The first block is the base prompt - the general description of the whole image. Every block after it is a region prompt, and they come out in order, matched one-to-one against the mask list from Moon Mask Maker or its GUI sibling. That pairing is the whole deal: mask_list[i] gets conditioning[i+1].

How the encoding works

Without the fancy stuff, each BREAK-separated block goes through the standard ComfyUI CLIP encode, and the node collects the results into a list. But the real reason to use this node is the greedy toggle.

CLIP encodes in 77-token blocks, and long prompts get truncated - the trailing detail silently vanishes. Greedy mode fights that. It takes a region prompt, splits it into comma-separated sub-prompts, tokenizes each one individually, and greedily packs them into as few 77-token blocks as possible (with the comma tokens re-injected and a small space-bias trick so adjacent blocks don't glue words together). Then it concatenates the encoded blocks into one long conditioning instead of dropping the overflow. It's the same token-packing idea Omost's regional prompter popularized, and it's what keeps a big, comma-heavy prompt from losing its last few concepts.

The one thing to watch: greedy packs within a BREAK block. If you want each area to stay independent, put a BREAK between areas and let greedy pack the commas inside each one. If you don't enable greedy, the node is just a convenient multi-prompt encoder - each block gets the plain, truncating treatment.

The inputs and output

  • clip - the CLIP model from your checkpoint loader.
  • text (multiline) - the BREAK-separated prompt stack. Empty blocks are encoded as a "skip" marker so the samplers can leave that region out.
  • greedy (BOOLEAN, default off) - token packing for long prompts.

Output is a single CONDITIONING list. Wire it into the positive_list (and add a second one for negatives) of the Moon Regional Patcher or Moon Multi-Area KSampler.

Install

Part of ComfyUI-MoonNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/m0rtus59/ComfyUI-MoonNodes.git
cd ComfyUI-MoonNodes && pip install -r requirements.txt

Restart. No model files to download - it uses whatever checkpoint's CLIP you feed it.

Where people get burned

Index order is everything. The base prompt is block 0, and region prompt n lines up with mask nβˆ’1. If your text has two BREAKs (three blocks) but your mask maker produced two masks, the third region prompt gets dropped. And the delimiter is the exact word BREAK - a stray space changes nothing, but a stray break lowercase won't split. Finally, greedy is a modest encode-time cost for a real quality win on long prompts; if you're not near the 77-token limit, leaving it off is fine and faster. Start with it off, flip it on the moment a prompt starts silently shedding words.

CategoryMoonNodes

Inputs (3)

NameTypeDefaultDescription
clipCLIPβ€”
textSTRINGβ€”
greedyBOOLEANfalseβ€”

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONINGβ€”