ComfyUI Node

compare

Diff two dictionaries and see exactly what changed

By StableLlama·Created about a year ago·Updated 4 days ago· 48
compare
  • dict1
  • dict2
  • are_equal
  • only_in_dict1
  • only_in_dict2
  • different_values

Dictionaries are ComfyUI's way of carrying around labeled bundles of data - metadata blobs, model info, config maps - and sometimes you need to know whether two of them differ, and how. DictCompare takes two dictionaries and hands you a full breakdown of the difference: whether they're equal, which keys exist in only one, and which shared keys have different values.

Inputs: dict1 and dict2, both DICT type. Outputs are the useful part, and there are four of them:

  • are_equal - a BOOLEAN, True if the dictionaries are identical.
  • only_in_dict1 - a LIST of keys present in the first but not the second.
  • only_in_dict2 - a LIST of keys present in the second but not the first.
  • different_values - a LIST of keys that exist in both but hold different values.

How it works

Mechanically it compares the key sets, computes the symmetric differences, and then checks every shared key for value inequality. The equality check is Python's == on the whole dict, so nested dictionaries compare by structure, not by reference - two separately-built dicts with the same content count as equal. That's the behavior you want in practice.

The output LIST values are Python lists as single variables (the pack's LIST type, not data lists), so if you want to process the changed keys as individual items, route them through the pack's ListToDataList converter first.

Where it earns its keep

This node shines wherever things change between runs. Compare the metadata from two loaded images to detect if they came from the same workflow settings. Compare a stored config against a freshly built one to decide whether anything actually changed before you spend compute. Use are_equal as a branch condition - if nothing changed, skip the expensive step. The different_values list is your "what to investigate" report, and it's the output people underuse: it tells you where to look, not just that something's different.

Installing it

Part of StableLlama's Basic data handling pack - pure Python, zero dependencies, no models:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart ComfyUI, or search "Basic data handling" in ComfyUI Manager. No requirements.txt to fight with - the pack ships dependency-free.

Common issues

Two things trip people up. First, the output lists are keys, not values - different_values tells you which keys differ, not what the old and new values are; pulling those is a separate DictGet step. Second, remember the equality check is deep and exact: 1 and 1.0 compare equal in Python, but "1" (string) does not equal 1 (number). If a comparison you expected to pass is failing, check the types of the values, not just the values.

CategoryBasic/DICT

Inputs (2)

NameTypeDefaultDescription
dict1DICT
dict2DICT

Outputs (4)

NameTypeDescription
are_equalBOOLEAN
only_in_dict1LIST
only_in_dict2LIST
different_valuesLIST