ComfyUI > Nodes > Basic data handling > filter by keys

ComfyUI Node: filter by keys

Class Name

Basic data handling: DictFilterByKeys

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

filter by keys Description

Filters dictionaries by extracting specified key-value pairs for efficient data management.

filter by keys:

The DictFilterByKeys node is designed to streamline the process of extracting specific key-value pairs from a dictionary based on a list of desired keys. This node is particularly useful when you need to focus on a subset of data within a larger dataset, allowing you to efficiently manage and manipulate dictionaries by filtering out unnecessary information. By leveraging this node, you can ensure that only the relevant data is retained, which can be crucial for tasks that require precise data handling and analysis. The node intelligently determines the most efficient way to filter the dictionary, either by iterating over the keys or the dictionary itself, depending on the size of the input and the keys list. This optimization ensures that the filtering process is both fast and effective, making it an essential tool for AI artists who need to manage complex data structures without delving into the technical intricacies of dictionary operations.

filter by keys Input Parameters:

input_dict

The input_dict parameter represents the dictionary from which you want to filter specific key-value pairs. This parameter is crucial as it serves as the source data that will be processed by the node. The dictionary can contain any type of keys and values, and the node will handle the filtering based on the keys you specify. There are no minimum or maximum values for this parameter, but it should be a valid dictionary object.

keys

The keys parameter is a list of keys that you want to retain in the filtered dictionary. This list determines which key-value pairs will be included in the output. If the list is empty, the node will return an empty dictionary of the same type as the input. The keys should match the type of keys used in the input_dict, and there are no specific constraints on the number of keys you can provide.

filter by keys Output Parameters:

filtered_dict

The filtered_dict is the output parameter that contains the dictionary with only the key-value pairs specified by the keys parameter. This output is crucial as it provides a streamlined version of the original dictionary, containing only the data you need. The type of the output dictionary is preserved from the input, ensuring consistency in data handling. If no keys match, an empty dictionary of the same type as the input is returned.

filter by keys Usage Tips:

  • Use the DictFilterByKeys node when you need to focus on specific data points within a larger dataset, allowing for more efficient data processing and analysis.
  • Ensure that the keys list accurately reflects the keys you want to retain in the dictionary to avoid unnecessary data loss.
  • Consider the size of your input_dict and keys list, as the node optimizes the filtering process based on their relative sizes for better performance.

filter by keys Common Errors and Solutions:

Empty dictionary returned

  • Explanation: This occurs when the keys list is empty or none of the keys in the list match those in the input_dict.
  • Solution: Verify that the keys list contains the correct keys you wish to filter and that these keys exist in the input_dict.

Type mismatch error

  • Explanation: This error can happen if the keys list contains elements that are not compatible with the key type of the input_dict.
  • Solution: Ensure that all elements in the keys list are of the same type as the keys in the input_dict to prevent type mismatch issues.

filter by keys 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.

filter by keys