Extensions/🗂️ Dict Tools
ComfyUI Extension

🗂️ Dict Tools

Essential nodes to use dictionaries in ComfyUI: for smart prompt-formatting, general organization (passing a single connection instead of spaghetti), or anything else.

By Lex-DRL·Created 4 months ago·Updated 4 months ago· 1
Lex-DRL/ComfyUI-DictTools
Nodes50
On cloudLocal install
Category🗂️ Dict Tools/Add, 🗂️ Dict Tools/Add/Models
Stars1
Updated4 months ago

Nodes (50)

◯ANY → Dict🗂️

Shove Anything Into a Dict

🗂️ Dict Tools/Add
◯ANY-Key◯ → Dict🗂️

Dictionaries With Dict-of-Your-Choice Keys

🗂️ Dict Tools/Add
bool → Dict🗂️

Store a Yes/No in Your Dict

🗂️ Dict Tools/Add
🟡CLIP → Dict🗂️

Carry the Text Encoder in Your Bus

🗂️ Dict Tools/Add/Models
🔵CLIP-vision → Dict🗂️

The Vision Encoder, On the Bus

🗂️ Dict Tools/Add/Models
🟠Cond → Dict🗂️

Bundle Your Conditioning Into the Bus

🗂️ Dict Tools/Add
🟢ControlNet → Dict🗂️

Bundle Your ControlNet Into the Bus

🗂️ Dict Tools/Add/Models
float → Dict🗂️

The Denoise Value, Finally in One Place

🗂️ Dict Tools/Add
🟤GLIGEN → Dict🗂️

The GLIGEN Model, Parked in the Dict

🗂️ Dict Tools/Add/Models
Guider → Dict🗂️

The Guider, Boxed and Ready

🗂️ Dict Tools/Add/Advanced
🔵Image → Dict🗂️

Images In, One Wire Out

🗂️ Dict Tools/Add
int → Dict🗂️

Park a Number in the Dict Without a Wire

🗂️ Dict Tools/Add
🟣Latent → Dict🗂️

Keep Your Latents Off the Spaghetti Heap

🗂️ Dict Tools/Add
⚪LoRA → Dict🗂️

Stack Your LoRAs Into the Bus

🗂️ Dict Tools/Add/Models
🟢Mask → Dict🗂️

The Mask That Rides Along

🗂️ Dict Tools/Add
🟣Model → Dict🗂️

Your Checkpoint, Packed Into the Bus

🗂️ Dict Tools/Add/Models
Noise → Dict🗂️

Your Noise Source, Parked in the Bus

🗂️ Dict Tools/Add/Advanced
Sampler → Dict🗂️

The Sampler Object, On Board

🗂️ Dict Tools/Add/Advanced
Sigmas → Dict🗂️

The Sigma Schedule, Rides Along

🗂️ Dict Tools/Add/Advanced
string → Dict🗂️

Your prompts, one key at a time

🗂️ Dict Tools/Add
🟢Upscale → Dict🗂️

Stash your upscaler on the bus

🗂️ Dict Tools/Add/Models
🔴VAE → Dict🗂️

Keep your VAE from being the wildcard

🗂️ Dict Tools/Add/Models
🗂️Dict → ANY◯

The untyped escape hatch for your dict

🗂️ Dict Tools/Extract
🗂️Dict → ◯ANY-Key◯

For when your dict keys aren't strings

🗂️ Dict Tools/Extract
🗂️Dict → bool

The on/off switch living inside your dict

🗂️ Dict Tools/Extract
🗂️Dict → CLIP🟡

One CLIP, shared across every text encoder

🗂️ Dict Tools/Extract/Models
🗂️Dict → CLIP-vision🔵

Route your CLIP-vision through the bus

🗂️ Dict Tools/Extract/Models
🗂️Dict → Cond🟠

Your conditioning, extracted on demand

🗂️ Dict Tools/Extract
🗂️Dict → ControlNet🟢

ControlNet presets, as dict entries

🗂️ Dict Tools/Extract/Models
🗂️Dict → float

Every denoise, strength, and CFG, in one place

🗂️ Dict Tools/Extract
🗂️Dict → GLIGEN🟤

The rare GLIGEN extractor, for grounding boxes

🗂️ Dict Tools/Extract/Models
🗂️Dict → Guider

For the advanced-sampling crowd

🗂️ Dict Tools/Extract/Advanced
🗂️Dict → Image🔵

Pull images out of the bus when you need them

🗂️ Dict Tools/Extract
🗂️Dict → int

Seeds, steps, and sizes, keyed and centralized

🗂️ Dict Tools/Extract
🗂️Dict → Latent🟣

Pass latents around without losing the plot

🗂️ Dict Tools/Extract
🗂️Dict → LoRA⚪

Your LoRA stack, carried by one wire

🗂️ Dict Tools/Extract/Models
🗂️Dict → Mask🟢

Masks in the bus, applied where they matter

🗂️ Dict Tools/Extract
🗂️Dict → Model🟣

Pull the Checkpoint Back Out of the Bus

🗂️ Dict Tools/Extract/Models
🗂️Dict → Noise

Noise objects, keyed for the sampler purists

🗂️ Dict Tools/Extract/Advanced
🗂️Dict → Sampler

Carry your sampler selection in the bus

🗂️ Dict Tools/Extract/Advanced
🗂️Dict → Sigmas

Pull the noise schedule out of a dict

🗂️ Dict Tools/Extract/Advanced
🗂️Dict → string

The Dict Tools node you'll actually reach for every day

🗂️ Dict Tools/Extract
🗂️Dict → Upscale🟢

Keep your upscaler of choice in the bus

🗂️ Dict Tools/Extract/Models
🗂️Dict → VAE🔴

Decode straight from the bus

🗂️ Dict Tools/Extract/Models
📃Text → Dict🗂️ [OLD]

Text → Dict, wearing its old ID

🗂️ Dict Tools/_old
◯ANY → Dict🗂️ [OLD]

The legacy ANY → Dict node, explained

🗂️ Dict Tools/_old
string → Dict🗂️ [OLD]

Add a prompt chunk the legacy way

🗂️ Dict Tools/_old
🗂️Dict → string [OLD]

The legacy Dict → string, and its literal-key trap

🗂️ Dict Tools/_old
📃Text → Dict🗂️ [OLD]

Text → Dict, first generation (look for the 'strings' input)

🗂️ Dict Tools/_old
📃Text → Dict🗂️

Build a whole prompt bundle from one text box

🗂️ Dict Tools
Readme

"Do one thing and do it well." — Peter H. Salus / Doug McIlroy, core Unix principle

"Simple is better than complex." — Zen of Python

<div align="center">

🗂️ Dict Tools for ComfyUI

Essential nodes to use dictionaries in ComfyUI: for smart prompt-formatting, general organization (passing a single connection instead of spaghetti), or anything else.<br />

</div>

TL;DR

  • In python, there's a built-in "dictionary" (dict) data type.
  • It's both simple and powerful: it's a single container that lets you put many pieces of data into it, and still access them individually - by their unique names aka keys. For example, you can put there:
    • seed (int)
    • denoise value (float)
    • text prompt (string)
    • ... and even have multiple versions of them for different stages of workflow - as long as each value has its own unique key.
  • Even though ComfyUI actively uses dicts under the hood, there's no built-in DICT data type exposed to users, nor there are any nodes to build/modify/use dicts.
  • This node pack aims to fix that.

[!IMPORTANT] I highly recommend using it together with:

  • Basic Data Handling pack. It exposes all the built-in python methods to work with dicts as ComfyUI nodes.
  • My other String Constructor/Formatter node. I will NOT pile up all my nodes into another one uber-mega "Comfy-Darlog-Tools" pack. Install only what wou need, separately.

What for?

In short:

  • Advanced text formatting;
  • Utilizing the well-known "bus" workflow to reduce spaghetti, while letting you decide what categories of data are contained inside the bus - not the node author deciding for you;
  • Any other uses for dicts - your choice!

Now, specifics.

Formatting

Originally, all these nodes were just a part of my String Constructor pack as "supporting" nodes. So they let you prepare a dictionary with various text chunks, and then build the actual prompt from them, easily reusing the same descriptions across the workflow. Like this:

example-graph-with-constructor

Bus connection

... but it quickly became apparent, that dicts are good not only for that - they're perfect as general-purpose "wrappers" over big sets of any data, no matter what is its type. So:

  • You put all your seeds/prompts/denoise values/whatever (even models) into a single dictionary.
  • You pass it as a single connection across the graph.
    • Yes, if you wish, also using any other spaghetti-reducing nodes - like Set/Get nodes from KJNodes pack or any nodes from UE pack.
  • When needed, you extract these values back from the dict and connect them as usual. No special bus-understanding nodes required.

Also, dicts are designed to be easily updated, so you could initially build one "base" dict, another "override" dict, and somewhere down the workflow you apply the latter - getting a third dict which preserves all the original values from the first one, but takes the updated values from the second one.

This "base-then-override" approach lets you build your own templates containing entire sets of values, applied all at once with a single node when you need it. If you're familiar with Automatic1111 UI, then it's basically a "style preset" concept, but much, much, MUCH more flexible and powerful.

Examples 🚧🏗️

(Section under construction)

Implementation details for programmers

The exact datatype the nodes in this pack output is actually frozendict (not native dict) - to prevent accidentally mutating the same dict by multiple nodes.

Versioning scheme

I adopted a custom versioning scheme, which looks like a regular SemVer, but is slightly different:

  • First number is internal node-API version.
  • Second is major update - when it bumps, it contains breaking changes.
  • Last is a minor update.

TODO.md