ComfyUI Node

Dict Get

Pull one value out of a dict and get it in six flavors

By turnbros·Created 11 months ago·Updated 10 months ago· 0
Dict Get
  • py_dict
  • as_string
  • as_int
  • as_float
  • as_bool
  • as_dict
  • as_list
key
default

Dict Get is the keyhole into any PYDICT. You hand it a dictionary and a key, and it digs the value out - then hands it back to you in six type flavors at once, because ComfyUI doesn't do dynamic types and someone had to cover the bases. It's the natural second half of the JsonParse flow, and it's where "parse a JSON API response" stops being a pain and becomes a two-node habit.

Here's the shape of a real use: your workflow calls an image API that returns a big JSON blob with width, height, seed, and a parameters object nested inside. You parse it with JsonParse, wire the py_dict into Dict Get, type parameters.seed as the key, and the seed comes out as an integer you can feed straight into a sampler node. That's the whole point - API output goes from opaque text to a value you can wire.

The inputs that matter

  • py_dict (required) - the dictionary to search. Comes from a JsonParse node or any other PYDICT source.
  • key (required) - the lookup key, and it supports dot notation. parameters.seed walks nested dicts. settings.width too. This is the single most useful feature and easy to miss, because the field just looks like a plain text box.
  • default (optional) - a fallback value if the key doesn't exist. The catch: it's parsed as JSON first, so "42" (with quotes) gives you the number 42, while 42 also gives you 42, and plain text gives you a string. Empty string means "no default," and you get None instead.

The six outputs, and which to use

The node returns as_string, as_int, as_float, as_bool, as_dict, and as_list. Every value is coerced into all six types where possible; where a coercion fails, that output is None.

  • as_string is your safe bet - every value becomes a string, including dicts and lists (JSON-serialized).
  • as_int / as_float / as_bool - pick the type that matches what the target node wants. "3" coerces to int 3; "true", "yes", "1" coerce to bool True; "false", "no", "0" to False.
  • as_dict / as_list - only populated if the value actually is a dict or list. Wire these when you want to drill one level deeper or iterate.

The trap beginners hit: they wire as_int for a value that can't coerce, get None, and blame the node. If you're not sure what type the value is, grab as_string first and look at it.

Installing it

ComfyBros installs like any custom node pack - ComfyUI Manager, search "ComfyBros", install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/turnbros/ComfyBros

The pack's README is stale (it references a requirements.txt that doesn't exist; the real deps are in pyproject.toml and Manager installs them). Dict Get lives under ComfyBros/JSON.

Gotchas

Missing keys with no default raise a KeyError, so if your workflow dies complaining about a key, either the JSON shape changed or your dotted path has a typo - parameters.seed and parameters.seeds are not the same. Dotted paths also mean a key that literally contains a period can't be reached; that's rare, but it's the one real limitation.

CategoryComfyBros/JSON

Inputs (3)

NameTypeDefaultDescription
py_dictPYDICT
keySTRING
defaultoptSTRING

Outputs (6)

NameTypeDescription
as_stringSTRING
as_intINT
as_floatFLOAT
as_boolBOOLEAN
as_dictPYDICT
as_listPYLIST