ComfyUI > Nodes > Basic data handling > contains key

ComfyUI Node: contains key

Class Name

Basic data handling: DictContainsKey

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

contains key Description

The `DictContainsKey` node checks for a key's existence in a dictionary to prevent access errors.

contains key:

The DictContainsKey node is designed to help you determine whether a specific key exists within a given dictionary. This functionality is particularly useful when you need to verify the presence of a key before attempting to access its associated value, thereby preventing potential errors or exceptions. By providing a straightforward method to check for key existence, this node enhances the robustness of your data handling processes, ensuring that your workflows can gracefully handle scenarios where keys might be missing. This node is an essential tool for managing dictionaries effectively, allowing you to build more reliable and error-resistant applications.

contains key Input Parameters:

input_dict

The input_dict parameter represents the dictionary in which you want to check for the presence of a specific key. This parameter is crucial as it serves as the data source for the key existence check. There are no minimum or maximum values for this parameter, as it can be any dictionary. The dictionary should be structured with key-value pairs, where the keys are typically strings or other hashable types.

key

The key parameter is the specific key you want to check for within the input_dict. This parameter is a string and is essential for the node's operation, as it specifies the target key whose existence you wish to verify. The default value for this parameter is an empty string, but you should provide a meaningful key that you expect to find in the dictionary. The presence or absence of this key in the dictionary will determine the node's output.

contains key Output Parameters:

boolean

The output of the DictContainsKey node is a boolean value. This output indicates whether the specified key exists within the provided dictionary. If the key is found, the output will be True; otherwise, it will be False. This boolean result is crucial for decision-making processes in your workflows, allowing you to conditionally execute actions based on the presence or absence of the key.

contains key Usage Tips:

  • Use the DictContainsKey node to prevent errors when accessing dictionary values by ensuring the key exists before attempting to retrieve its value.
  • Combine this node with other dictionary manipulation nodes to create robust data processing pipelines that can handle missing keys gracefully.

contains key Common Errors and Solutions:

KeyError

  • Explanation: This error occurs when you attempt to access a key in a dictionary that does not exist.
  • Solution: Use the DictContainsKey node to check for the key's existence before accessing it, thereby avoiding the KeyError.

TypeError: unhashable type

  • Explanation: This error arises when you use a non-hashable type (like a list) as a key in a dictionary.
  • Solution: Ensure that the key parameter is a hashable type, such as a string or a number, to avoid this error.

contains key 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.

contains key