ComfyUI Node: invert

Class Name

Basic data handling: DictInvert

Category
Basic/DICT
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

invert Description

DictInvert node swaps keys and values in a dictionary, reversing data mapping for analysis.

invert:

The DictInvert node is designed to transform a given dictionary by swapping its keys and values, effectively inverting the dictionary. This operation is particularly useful when you need to reverse the mapping of data, such as when you want to look up keys by their values. The node ensures that the values in the original dictionary are hashable, as they will become the keys in the new dictionary. This inversion process can be beneficial in various scenarios, such as data transformation tasks, where the relationship between keys and values needs to be reversed for further processing or analysis. The node is robust, handling potential issues like unhashable values gracefully by returning the original dictionary and indicating a failure.

invert Input Parameters:

input_dict

The input_dict parameter is the dictionary that you want to invert. It serves as the source of data where the keys and values will be swapped. The effectiveness of this parameter depends on the hashability of the values in the dictionary, as they will become the keys in the inverted dictionary. There are no specific minimum or maximum values for this parameter, but it is crucial that the values are hashable to ensure a successful inversion. If the values are not hashable, the inversion will fail, and the original dictionary will be returned.

invert Output Parameters:

inverted_dict

The inverted_dict is the resulting dictionary after the inversion process, where the original keys have become values and the original values have become keys. This output is significant as it provides a reversed mapping of the original data, which can be used for various analytical or processing tasks. The success of this output depends on the hashability of the original values.

success

The success parameter is a boolean value that indicates whether the inversion was successful. A value of True means the inversion was completed without issues, while False indicates that the inversion failed, typically due to unhashable values in the original dictionary. This parameter is crucial for understanding the outcome of the inversion process and for handling any potential issues that may arise.

invert Usage Tips:

  • Ensure that all values in the input_dict are hashable, as this is a prerequisite for them to become keys in the inverted dictionary.
  • Use the success output to verify if the inversion was successful, and handle cases where it returns False by checking the original dictionary for unhashable values.

invert Common Errors and Solutions:

Unhashable values in dictionary

  • Explanation: The inversion process requires that all values in the original dictionary be hashable, as they will become keys in the new dictionary. If any value is unhashable, the inversion will fail.
  • Solution: Check the values in your dictionary to ensure they are hashable types, such as strings, numbers, or tuples. Avoid using lists or other mutable types as values.

Duplicate values in dictionary

  • Explanation: If the original dictionary contains duplicate values, only the last key-value pair will be retained in the inverted dictionary, as keys must be unique.
  • Solution: Be aware that duplicate values will result in data loss during inversion. Consider preprocessing your dictionary to handle duplicates if retaining all data is necessary.

invert Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

invert