ComfyUI Node

Set Nested Dict

Nest one dict inside another in ComfyUI

By antrobot1234·Created 3 years ago·Updated about a year ago· 28
Set Nested Dict
  • Dict Value
  • DICT
  • DICT
key

Once you've been bundling values with the antrobots dict nodes for a while, your one bundle starts getting big and flat - twenty keys all at the same level. Set Nested Dict (class name setDictDict) is the node that adds a layer of structure: it takes an entire DICT and files it inside another DICT under a single key. In other words, a dict within a dict, so you can group related values into named sections instead of one long list.

This is the advanced corner of the dict family. The rest of the pack packs individual values - a string here, an int there - into one keyed container so it can travel across the graph on a single wire, the same graph-tidying idea behind rgthree's Context nodes. Set Nested Dict works one level up: it bundles a whole bundle.

Why you'd nest

Namespacing, basically. Say you've built one sub-bundle for your sampler settings (steps, cfg, denoise) and another for your upscale settings (model, factor, tile size). Rather than dumping all six keys into a single flat dict where steps and factor sit side by side, you nest each group under its own key - sampler and upscale - and fetch the section you want as a unit. On the read side, a Get Dict pulls back the whole sub-dict, which you can then unpack further. It keeps a large bundle organized and keeps key names from colliding when two groups happen to reuse the same label.

Honestly, for a small workflow this is overkill - flat is simpler and you should stay flat until the bundle genuinely gets unwieldy. Reach for nesting when a single dict has grown big enough that grouping actually helps you find things.

How it works

A dict here is a Python dictionary carried on a custom DICT wire. Give the node a key and a Dict Value (itself a DICT) and it creates a new one-key bundle whose value is that whole inner dict. Give it a key, a Dict Value, and an existing outer DICT, and it files the inner dict into that outer one under the key and passes the result forward. Same chaining model as the rest of the family - the difference is the value you're storing is a bundle, not a scalar.

The inputs and outputs that matter

  • key (string) - the section name the nested dict lives under, matched exactly by Get Dict.
  • Dict Value (DICT) - the inner bundle you're filing away. Wired in from another Set Dict chain; no widget.
  • DICT (optional) - the outer bundle to append the section to; empty starts a new one.

Output is a single DICT - now with a nested bundle inside it - headed for the next Set Dict or a Get Dict.

Installing it

Install the whole pack. Via ComfyUI Manager: Install Custom Nodes, search antrobots ComfyUI Nodepack, install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/antrobot1234/antrobots-comfyUI-nodepack

then restart ComfyUI. No models, no heavy dependencies, just Python - the install is quick and quiet.

Common issues

Nesting is where people lose track of their own structure. When you pull the section back out with a Get Dict, you don't get a value - you get the inner dict, which you then have to unpack with another Get Dict using the inner keys. Two levels in, two Get Dicts out. If a "missing" value turns out to be a whole dict, you've unpacked one layer too few.

Keep a mental note of your Dict Value versus your DICT input, too - it's easy to wire the section into the wrong port and end up filing your outer bundle inside the inner one. And the family basics still hold: keys match as exact strings (a typo silently returns a default), and the DICT type is antrobots-only, unpacked through Get Dict and never fed to a stock node. Since this is a small, single-maintainer pack with essentially no community discussion, the README's suggestion to open a GitHub issue is your realistic support channel if you hit a genuine bug.

Categoryantrobots-ComfyUI-nodepack/dicts/set

Inputs (3)

NameTypeDefaultDescription
keySTRING
Dict ValueDICT
DICToptDICT

Outputs (1)

NameTypeDescription
DICTDICT