Extensions/ZF-ComfyUI-Helper
ComfyUI Extension

ZF-ComfyUI-Helper

Small, high-compatibility helper nodes for ComfyUI input validation, resolution selection, size presets, and basic workflow settings.

By Z-yaofang·Created about a month ago·Updated 16 days ago· 1
Z-yaofang/ZF-ComfyUI-Helper
Nodes
On cloudLocal install
Stars1
Updated16 days ago
Readme

ZF-ComfyUI-Helper

简体中文

Small, high-compatibility helper nodes for ComfyUI input and basic workflow settings.

This plugin is intended to be a lightweight toolbox for practical workflow setup tasks: resolution selection, input helpers, shared settings, and other small utility nodes that are useful across many models and workflows. Node names use the ZF prefix so they are easy to find in ComfyUI search.

Nodes

ZF Any Filter

Places an explicit filter between any data source and a node such as rgthree Any Switch. It accepts text, lists, images, tensors, pose data, numbers, booleans, dictionaries, and other ComfyUI values. Empty lists are normalized safely, while valid values such as 0 and False are preserved.

Condition and Output are independent selectors. A matching condition can emit None so Any Switch skips that route, emit "" so it intentionally stops on that route, preserve the input, or remove literal text. Unmatched values always pass through unchanged. Text rules are entered one per line and do not use regular expressions.

Common combinations:

  • Input is empty + No output: safely skip empty routes.
  • Always + Empty text: intentionally block every text value on this route.
  • Text contains any item + No output: skip text containing an unwanted marker.
  • Text contains any item + Remove specified content: remove selected words or symbols while preserving the rest.

ZF Multi Text Switch

Displays 1-32 text inputs according to input_count and provides an exclusive route button for each visible input. Execution requests only the selected route; other routes are not evaluated, and there is no content-based fallback. Selecting an unconnected or empty route outputs an empty string. The dedicated Empty Text button outputs "" with route index 0, and the second output reports the explicit selection.

ZF EasySize Image

Resizes an optional image and mask using generic dimensions, a custom size, or target longest/shortest side length.

The preset list is model-neutral. Duplicate dimensions are removed and the remaining AI-friendly multiples of 8 are grouped into landscape, portrait, and square submenus. Each group is ordered by pixel area from smallest to largest. If grouped combo menus are disabled, the same group and size order is retained in one flat list.

The dimensions themselves are reusable, but the downstream model still decides which pixel range and latent format it supports.

Resize modes:

  • preset: use one of the built-in generic dimensions.
  • custom: use custom width and height.
  • longest_side: preserve the input image or mask ratio and set the longest side.
  • shortest_side: preserve the input image or mask ratio and set the shortest side.

Crop modes:

  • center_crop: fill the target size and crop from the center.
  • stretch: resize directly to the target size.

Outputs:

  • image
  • mask
  • width
  • height
  • summary

ZF 简易尺寸

Outputs width and height from the generic EasySize dimensions or a custom size without creating image or latent data. Connect these outputs to the target model's native empty-latent node.

Outputs:

  • width
  • height
  • summary

ZF Resolution Selector

Calculates width and height from a ratio, optional reference image, target side length, target megapixels, and rounding rules.

It does not resize images and does not create latent tensors. It only outputs clean numeric settings that can be connected to ComfyUI nodes such as EmptyLatentImage, sampler helpers, resize nodes, or workflow setting nodes.

Supported ratio modes:

  • original: use the optional input image size and ratio. If no image is connected, fall back to custom width and height.
  • custom: use custom width and custom height as the ratio and base size.
  • Common fixed ratios such as 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, 21:9, 9:21, 2:1, 1:2, 5:4, 4:5, 3:1, and 1:3.

Scale modes:

  • none: keep the base size for original or custom; fixed ratios use the larger custom side as the longest side.
  • longest: set the longest side to target_length.
  • shortest: set the shortest side to target_length.
  • width: set output width to target_length.
  • height: set output height to target_length.
  • megapixels: keep the selected ratio and solve width/height from target_megapixels.

Rounding:

  • round_to_multiple: 1, 8, 16, 32, 64, or 128.
  • round_mode: nearest, down, or up.

Outputs:

  • width
  • height
  • megapixels
  • summary
  • source_width
  • source_height

Why It Exists

Resolution control is useful in far more than one model workflow. Keeping this as a small general helper plugin avoids depending on large node packs when all you need is stable width and height selection.

The first node is inspired by practical aspect-ratio selector workflows, but implemented as a clean standalone utility with no external dependencies.

Frontend Helpers

Folder-style combo menus

ComfyUI model lists often contain relative paths such as Qwen/model.safetensors. This helper groups path-like combo menus into folder submenus while preserving the original full value when a model is selected.

It is enabled by default and can be toggled in ComfyUI settings:

  • ZF Helper: group path-like combo menus

The helper skips ComfyUI-Custom-Scripts checkpoint and LoRA loader menus because that extension already manages its own tree and preview behavior for those nodes.

Workflow drag/drop fallback

Some frontend/plugin combinations can fail to load workflows when dropping files directly onto the canvas. This helper adds a conservative fallback for workflow-like files:

  • .json
  • .png
  • .webp
  • .jpg
  • .jpeg
  • .svg

It ignores text fields, buttons, dialogs, and context menus, then passes the dropped file to ComfyUI's built-in app.handleFile(...) loader.

ZF Load Single Latent

Loads one safetensors-style latent file from a local folder path.

Supported extensions:

  • .latent
  • .safetensors
  • .sft

The file name suffix is optional. For example, 001 (1) resolves to 001 (1).latent.

Outputs:

  • latent
  • file_path

ZF Load Latent Folders

Loads latent files from up to 10 local folders. Each folder input has a matching latent-list output.

This is useful when you want to feed latent batches from fixed local paths without using browser upload dialogs or file picker nodes.

ZF Load Single Tensor Latent

Loads one PyTorch tensor latent from a local folder path.

Supported extensions:

  • .pt
  • .pth

If the file contains a full ComfyUI latent dict with samples, it is preserved. If it contains only a tensor, the node wraps it as {"samples": tensor}.

ZF Load Tensor Latent Folders

Loads .pt or .pth tensor latent files from up to 10 local folders.

Safety note: .pt and .pth files use PyTorch pickle loading. Only load tensor latent files that you created yourself or fully trust.

ZH Save Image

Saves PNG images to the normal ComfyUI output directory without writing prompt, workflow, or extra PNG metadata.

It is intentionally named with ZH at the front so it is easy to distinguish from ComfyUI's built-in Save Image node while keeping similar behavior and output preview.

ZF Save TXT (Timestamp)

Saves input text as a UTF-8 .txt file. A relative directory such as TXT is created below ComfyUI's normal output folder; an absolute local path can also be used. Missing folders are created automatically.

Blank lines and line endings in a single string are preserved. When the upstream node provides a ComfyUI string list, the complete list is written to one TXT in order instead of creating one file per item.

The filename combines the custom prefix with local date and time, for example:

reverse_prompt_2026-07-23_23-45-12.txt

The node outputs both the original text and the actual saved file path for downstream reuse.

ZF Load TXT

Loads one TXT from a folder and returns its complete text without removing blank lines. Relative folders start below ComfyUI's output directory; absolute local paths are also supported.

The file-name value excludes the .txt extension. For example, to load E:\Text Archive\result.txt, use E:\Text Archive as the directory and result as the file name.

The node scans the selected folder, lists TXT names by most recently modified, and refreshes automatically after the directory changes. A manual refresh button is also available. The output can be connected directly to any downstream text-cleaning node.

Installation

Clone this repository into your ComfyUI custom_nodes directory:

git clone https://github.com/Z-yaofang/ZF-ComfyUI-Helper.git

Restart ComfyUI after installation or updates.

Localization

The default repository language and node definitions are English. A Simplified Chinese locale is included under locales/zh/nodeDefs.json for ComfyUI setups that load locale files.

Notes

  • This plugin has no model dependency.
  • This plugin does not include workflows yet.
  • The goal is to keep helper nodes small, predictable, and easy to reuse across different ComfyUI workflows.
  • ZF Load Single Tensor Latent and ZF Load Tensor Latent Folders should only be used with trusted .pt / .pth files.