ComfyUI Node

Any To Dict

Peek inside an unfamiliar object when you're debugging a workflow

By godmt·Created 2 years ago·Updated 2 months ago· 16
Any To Dict
  • ANY
  • DICT
  • str()

ComfyUI custom nodes pass around plenty of objects that aren't plain dicts, strings, or numbers - a CONDITIONING value, a custom class from some other pack, an internal object you've never had to look inside before. When you need to know "what's actually in this thing," Any To Dict is a quick debug probe: it tries to turn whatever you feed it into a dict you can inspect, and also gives you a plain string representation as a backup.

How it works

If the input is already a dict, it passes through unchanged. If it's a Python object that has a __dict__ (most custom classes do, unless they specifically opt out with __slots__), the node converts it using Python's vars(), which hands back the object's attribute names and values as a dict - genuinely useful for reverse-engineering what fields a class from an unfamiliar pack actually carries. If neither applies - a plain string, a number, something without an inspectable attribute dict - you get back an empty dict rather than an error.

Alongside that, the str() output always gives you the object's string representation regardless of whether the dict conversion worked, which is handy as a fallback: sometimes a class defines a nice __repr__/__str__ that tells you more at a glance than the raw attribute dump does. Between the two outputs, this node is essentially "give me whatever you can about this mystery value," aimed squarely at debugging rather than production use.

The inputs and outputs that matter

  • ANY - the value to inspect. Works on dicts (pass through), objects with __dict__ (converted via vars()), and anything else (falls back to an empty dict for the DICT output, while str() still works).

Two outputs: DICT, the object as a dict when conversion is possible, and str(), the plain string representation of the input regardless. Neither is meant to feed a production pipeline downstream - pair this with a text preview node to actually read the result, or use it temporarily while building a workflow and remove it once you understand what you're working with.

How to install it

ComfyUI Manager: search "ComfyUI-List-Utils," install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/godmt/ComfyUI-List-Utils.git

Restart ComfyUI. No dependencies beyond the base pack - this node is pure introspection, vars() and str() from the Python standard library.

Common issues & troubleshooting

DICT output comes back empty even though you're sure the object has data. That happens with objects that don't expose a __dict__ - classes using __slots__ for memory efficiency are the common case, and some C-extension or PyTorch-adjacent objects behave this way too. The str() output is your fallback there; if that's also unhelpful, the object may need a purpose-built inspection node, or you're better off reading the source of whatever pack produced it.

Dict has a lot of internal-looking keys you didn't expect. vars() gives you everything in the object's instance dict, including private-by-convention attributes (ones starting with an underscore) that the author didn't necessarily mean for you to poke at directly. That's normal for a debug tool - just be aware you're looking at implementation details, not a stable public interface, and don't build a workflow that depends on a specific internal field surviving a pack update.

Trying to use this as a real data-transformation step in a saved workflow. It's not built for that - treat it as a temporary probe while you're figuring out an unfamiliar node's output, then remove it (or bypass it) once you know what you need and can wire directly to the right field.

Categorylist_utils

Inputs (1)

NameTypeDefaultDescription
ANY*Any value to inspect. dict values pass through; objects with __dict__ are converted with vars().

Outputs (2)

NameTypeDescription
DICTDICTThe value as a dict. Returns an empty dict when conversion is not available.
str()STRINGThe str() representation of the input value.