Extensions/ComfyUI-FairLab
ComfyUI Extension

ComfyUI-FairLab

Utility, text, logic, and image helper nodes for ComfyUI with updated IO typing and safer script evaluation.

By yanhuifair·Created 2 years ago·Updated 3 months ago· 2
yanhuifair/ComfyUI-FairLab
Nodes58
On cloudLocal install
CategoryFair/logic, Fair/string
Stars2
Updated3 months ago

Nodes (58)

Add

Add Values (AddNode) — ComfyUI-LogicUtils

Fair/logic
Append Tags

Two tag lists, one deduped string — the node that merges without duplicating

Fair/string
ASCII Art Text

Banner your console — ASCII Art Text turns strings into block letters

Fair/string
Aspect Ratios

Aspect ratios without the mental math — pick a preset, get width and height

Fair/utility
Base64 To Image

From API string back to pixels — Base64 To Image decodes into a real tensor

Fair/image
Detail Map

Channel-packing for PBR — Detail Map packs albedo, normal, and smoothness into one texture

Fair/image
Divide

Divide (DivideNode) — ComfyUI-LogicUtils

Fair/logic
Download Image

The name is a lie — Download Image actually saves your images with alpha support

Fair/image
Exclude Tags

Strip the tags you don't want — Exclude Tags filters a comma-separated list

Fair/string
Fill Alpha

Flatten a transparent PNG onto a solid color — Fill Alpha kills the alpha channel

Fair/image
Fix UTF-8 String

Scrub the mojibake — Fix UTF-8 String turns garbled text into clean ASCII

Fair/string
Float

A decimal value that lives on the canvas — the Float node is a primitive you can wire

Fair/string
Float To Int

Truncation, not rounding — Float To Int drops the decimal and keeps the integer

Fair/logic
If

The graph as a tiny program — If routes one of two values based on a condition

Fair/logic
Image Remove Alpha

Flatten transparency onto a hex background — Image Remove Alpha composites by mask

Fair/image
Images Cat

Glue two image batches together — Images Cat concatenates along the batch axis

Fair/image
Image Shape

Read a tensor like a spec sheet — Image Shape reports batch, width, height, and channels

Fair/image
Images Index

Grab frame 7 (or the last one) — Images Index pulls a single image out of a batch

Fair/image
Image Size

Dimensions, sides, and aspect ratio in one read — Image Size reports everything at once

Fair/image
Images Range

Slice a batch like a Python list — Images Range trims frames with optional start and end

Fair/image
Image To Base64

Ship a PNG as text — Image To Base64 encodes your render for APIs and JSON

Fair/image
Image To Video

Frames to MP4 in one node — Image To Video encodes a folder of images into a video

Fair/image
Int

The FairLab Int node

Fair/string
Int To Float

The type-checker's peace offering

Fair/logic
Load Image Batch From Directory

One folder, one tensor

Fair/image
Load Image From Directory

Your whole folder, wired in

Fair/image
Load Image From URL

Grab a remote image without saving it first

Fair/image
Load String From Directory

Every caption file at once

Fair/string
Load String

Read a text file into the graph

Fair/string
Load LoRA Dual

Two LoRAs, one node, independent strengths

Fair/loaders
Mask Map

Four grayscale maps, one RGBA channel-pack

Fair/image
Max

Max (MaxNode) — ComfyUI-LogicUtils

Fair/logic
Min

Take the smaller of two values, no clamp node required

Fair/logic
Modulation Direction

The tiny preset that steers the effect

Fair/image
Modulation

Error-diffusion halftoning with a scan direction

Fair/image
Multiply Int

Integer math without the type mess

Fair/logic
Multiply

Multiply (MultiplyNode) — ComfyUI-LogicUtils

Fair/logic
Number

Nine derived values from one float

Fair/logic
Outpainting Pad

The math for a bigger canvas

Fair/image
Perfect Pixel

Upscale pixel art without the blur

Fair/image
Prepend Tags

Put the important words first

Fair/string
Print Any

What is actually in that wire?

Fair/utility
Print Image

Read your tensor's mind

Fair/utility
Pure Color Image

A blank canvas on demand

Fair/image
Python Script

A safe little calculator in your graph

Fair/utility
Range String

Batch naming without the spreadsheet

Fair/string
Resize Image

Force an exact width and height

Fair/image
Roughness To Smoothness

One line of math that saves you a renderer headache

Fair/image
Save Image To Directory

Put your output exactly where you want it, not in the default pile

Fair/image
Save Image To Folder

Batch exports with filenames that don't clobber each other

Fair/image
Save String To Directory

Get your prompts and captions onto disk, where they belong

Fair/string
Show String

The debugging node that sees text without breaking the wire

Fair/string
String Append

The glue node for building prompts from parts

Fair/string
String

The String node that just holds text — boring, and you'll use it constantly

Fair/string
String Translate

Free Google translation inside your graph, no API key — until it breaks

Fair/string
Subtract

The math node for when the sampler needs a number, not a guess

Fair/logic
Unique Tags

Dedupe your comma-separated prompt, then watch the order change

Fair/string
Video To Image

Turn clips into frame batches for img2img and training data

Fair/image
Readme

Language: 中文文档

<h1 align="center">ComfyUI-FairLab</h1> <p align="center"> <img src="https://img.shields.io/badge/ComfyUI-custom__nodes-blue?style=flat-square&logo=python" alt="ComfyUI Custom Nodes"> <img src="https://img.shields.io/badge/version-1.0.91-green?style=flat-square" alt="Version"> <img src="https://img.shields.io/badge/license-MIT-yellow?style=flat-square" alt="License"> <img src="https://img.shields.io/badge/nodes-58-orange?style=flat-square" alt="Nodes Count"> <a href="https://github.com/yanhuifair/ComfyUI-FairLab/stargazers"><img src="https://img.shields.io/github/stars/yanhuifair/ComfyUI-FairLab?style=flat-square" alt="GitHub stars"></a> </p> <p align="center"> A collection of 58 utility nodes for ComfyUI, spanning string processing, image I/O and manipulation,<br> arithmetic logic, PBR material tooling, and workflow diagnostics.<br> All nodes conform to the ComfyUI <code>IO.*</code> type annotation convention. </p>
<h2>Contents</h2>
<h2>Overview</h2>

ComfyUI-FairLab supplements the core ComfyUI node set with operations that are commonly needed in production workflows but not available in the base distribution.

| Category | Nodes | Scope | |:----------|:-----|:------| | String | 16 | String construction, tag manipulation, translation, encoding repair, file I/O | | Image | 26 | File/URL/Base64 loading, batch I/O, video conversion, alpha & channel ops, PBR maps, modulation | | Logic | 11 | Arithmetic operators, conditional branching, type casting | | Utility | 5 | Diagnostic printing, aspect ratio presets, dual LoRA loading, sandboxed scripting |


<h2>Installation</h2> <h3>Prerequisites</h3>
  • ComfyUI installed and working. If not, follow the official guide.
  • Python 3.10+ (the same environment ComfyUI uses).
  • Git (for manual installation).
<h3>Method 1: ComfyUI Manager (Recommended)</h3>
  1. Open ComfyUI and navigate to the Manager panel.
  2. Click Install Custom Nodes.
  3. Search for ComfyUI-FairLab.
  4. Click Install and restart ComfyUI.
<h3>Method 2: Manual Installation</h3>
# 1. Navigate to the custom_nodes directory
cd ComfyUI/custom_nodes

# 2. Clone the repository
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git

# 3. Enter the project directory
cd ComfyUI-FairLab

# 4. Install dependencies
pip install -r requirements.txt

# 5. Restart ComfyUI
<h3>Verify Installation</h3>

After restarting ComfyUI, double-click the canvas and search for FairLab or any node name (e.g., String Append, Load Image Batch From Directory). If the nodes appear in the search results, the installation was successful.

<h3>Updating</h3>

ComfyUI Manager: Click Update All in the Manager panel.

Manual:

cd ComfyUI/custom_nodes/ComfyUI-FairLab
git pull
pip install -r requirements.txt
<h3>Dependencies</h3>

| Package | Required By | |:--------|:------------| | googletrans | String Translate | | opencv-python | Video ↔ image; general processing | | requests | Download Image, Load Image From URL | | nest_asyncio | Async event loop support | | perfect-pixel[opencv]>=0.1.4 | Perfect Pixel |

<h3>Troubleshooting</h3>

Nodes not showing up after installation

  • Make sure you restarted ComfyUI after installing.
  • Check the ComfyUI terminal for import errors related to ComfyUI-FairLab.
  • Verify that dependencies were installed: pip list | grep -E "opencv|googletrans|perfect-pixel"

ImportError: No module named 'cv2'

pip install opencv-python

Google Translate not working

The googletrans library may require an updated version. Try:

pip install --upgrade googletrans

<h2>Node Reference</h2> <h3>String (16 nodes)</h3>

String construction, persistence, and tag-oriented manipulation.

| Node | Description | |:-----|:------------| | String | Emit a constant string value | | Int | Emit a constant integer value | | Float | Emit a constant floating-point value | | String Append | Concatenate multiple input strings into a single output | | Load String | Read string content from a local text file | | Save String To Directory | Write a string to a file on disk | | Load String From Directory | Read a string from a file in a specified directory | | Show String | Display a string value on the node's UI panel for inspection | | String Translate | Translate strings via Google Translate (source/target language configurable) | | Fix UTF-8 String | Repair malformed UTF-8 byte sequences (e.g., mojibake from encoding mismatches) | | Range String | Generate a sequence of indexed strings over a numeric range (e.g., frame_001..frame_100) | | Prepend Tags | Insert a prefix before each tag in a comma-separated list | | Append Tags | Append a suffix to each tag in a comma-separated list | | Exclude Tags | Remove specified tags from a tag list | | Unique Tags | Deduplicate entries in a tag list | | ASCII Art Text | Render text as an ASCII-art image using system fonts |

<h3>Image (26 nodes)</h3> <h4>I/O & Loading</h4>

| Node | Description | |:-----|:------------| | Load Image From Directory | Load a single image from a directory | | Load Image Batch From Directory | Load all images from a directory as a batch tensor | | Load Image From URL | Fetch an image directly from a remote URL into a tensor | | Download Image | Download a remote image and persist it to local disk | | Save Image To Directory | Write an image tensor to a specified output path | | Save Image To Folder | Save images organized by subdirectory | | Image To Base64 | Encode an image tensor as a Base64 string | | Base64 To Image | Decode a Base64 string into an image tensor |

<h4>Processing</h4>

| Node | Description | |:-----|:------------| | Resize Image | Resize an image tensor to target dimensions | | Image Size | Output the width and height of an image as scalar values | | Image Shape | Output the full tensor shape [B, C, H, W] of an image batch | | Image Remove Alpha | Strip the alpha channel from an RGBA image, producing RGB | | Fill Alpha | Add or replace the alpha channel on an RGB image | | Pure Color Image | Generate a solid-color image of configurable dimensions and RGB value | | Images Range | Slice a sub-range of images from a batch by start/end index | | Images Index | Extract a single image from a batch by index | | Images Cat | Concatenate multiple image batches along the batch dimension | | Outpainting Pad | Pad image borders for outpainting workflows | | Perfect Pixel | Integer-scale an image without sub-pixel interpolation (nearest-neighbor at exact multiples) |

<h4>Video</h4>

| Node | Description | |:-----|:------------| | Video To Image | Extract frames from a video file as an image batch tensor | | Image To Video | Compose an image batch into a video file (configurable FPS) |

<h4>Modulation</h4>

| Node | Description | |:-----|:------------| | Modulation | Apply error-diffusion modulation (Floyd–Steinberg-style halftoning) | | Modulation Direction | Directional error-diffusion with configurable scan direction and speed |

<h4>PBR Maps</h4>

| Node | Description | |:-----|:------------| | Mask Map | Convert a grayscale image into a normalized mask tensor | | Detail Map | Generate a detail map from an input image for PBR material pipelines | | Roughness To Smoothness | Convert between roughness and smoothness maps (invert) |

<h3>Logic (11 nodes)</h3>

Arithmetic and control-flow primitives for node-graph-level computation.

| Node | Description | |:-----|:------------| | Number | Generic numeric constant (INT / FLOAT toggle) | | Add | A + B with automatic INT/FLOAT type resolution | | Subtract | A - B | | Multiply | A × B with automatic type resolution | | Multiply Int | A × B with result cast to INT | | Divide | A ÷ B | | Max | max(A, B) | | Min | min(A, B) | | If | Conditional branch: route to output A or B based on a boolean condition | | Float To Int | Cast FLOAT to INT (truncation) | | Int To Float | Cast INT to FLOAT |

<h3>Utility (5 nodes)</h3>

Diagnostics, presets, and extensibility.

| Node | Description | |:-----|:------------| | Print Any | Print any input value to the console for debugging | | Print Image | Print image tensor metadata to the console (shape, dtype, value range) | | Aspect Ratios | Dropdown selector for common aspect ratios (1:1, 16:9, 4:3, 3:2, 2:3, 21:9) | | Load LoRA Dual | Load two LoRA models simultaneously with independent strength parameters | | Python Script | Evaluate a restricted Python expression in an AST-whitelist sandbox; supports arithmetic, comparison operators, and a curated set of builtins (abs, min, max, round, len, etc.). exec and eval are explicitly disabled. |


<h2>Technical Notes</h2>

Python Script sandbox

The expression evaluator uses an AST whitelist that permits only explicitly registered operators (+, -, *, /, //, %, **, <, >, <=, >=, ==, !=, is, is not, not, unary +/-) and built-in functions (abs, bool, float, int, len, max, min, round, sorted, str, sum, tuple, list). Arbitrary code execution via exec or eval is not possible.

IO typing

All nodes use the ComfyUI IO.* type annotations (IO.STRING, IO.IMAGE, IO.INT, IO.FLOAT, etc.), ensuring compatibility with the modern ComfyUI type system.

ASCII Art Text

Requires system font support. On minimal Linux installations, install a font package (e.g., fonts-dejavu-core on Debian/Ubuntu).

Video operations

Frame extraction and composition rely on opencv-python. Processing time scales with resolution and frame count.


<h2>License</h2>

MIT — see LICENSE.

Copyright (c) 2025 Fair