Nodes/honda-nodes/πŸ“‹ Array Filter
ComfyUI Node

πŸ“‹ Array Filter

Your prompt list minus the duplicates and the junk

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ“‹ Array Filter
    • Array
    • Count
    β—„arrayβ€”β–Ί
    β—„remove_emptytrueβ–Ί
    β—„remove_duplicatesfalseβ–Ί
    β—„patternβ–Ί
    β—„invert_patternfalseβ–Ί
    β—„trim_itemstrueβ–Ί

    First, the thing that confuses everyone

    The honda-nodes "array" nodes don't pass Python lists around. An array in this pack is a plain string with newlines in it - "cat\ndog\ncat\n" - and every node in the πŸ“‹ Array group parses that string, does one thing, and hands back another newline-joined string. Once that clicks, the whole group makes sense: it's a text-processing toolkit disguised as a collection library.

    Which makes Array Filter the workhorse of the group. You reach for it when the list arrived from somewhere you don't control - a tag dump pasted into a text node, a πŸ“‚ List Files result full of absolute paths, a prompt bank where somebody left blank lines and repeats in it. Filter is where you clean that up before anything downstream has to deal with it.

    What it actually does, in order

    The source is refreshingly honest about the sequence: trim β†’ remove empty β†’ dedupe β†’ pattern. That order is the whole node, and it matters. Trimming first means " cat" and "cat" collapse into one duplicate instead of two near-misses. Deduping keeps first occurrence, so your original ordering survives - no alphabetical surprise.

    The pattern field is a glob, matched with Python's fnmatch, not a regex. Two consequences people trip on:

    • cat does not match a cat on a mat. fnmatch matches the whole item, so you need *cat*. The bare word only matches an item that is exactly cat.
    • * matches slashes too, unlike a shell glob. So *.png on a list of absolute paths will happily match D:/outputs/run7/x.png. That's usually what you want here, and it's why this node is a decent pre-filter before hashing or deleting files.

    On Windows, fnmatch normalises case, so *.PNG matches .png. On Linux it doesn't, and that difference will bite you the day you move a workflow from your desktop to a rented GPU box. Leave Invert Pattern alone for a "keep only these" filter, enable it for "drop everything that looks like this" - dropping *.tmp off a file list, say.

    The inputs and outputs you'll touch

    Array is socket-only. You cannot click into it and paste your list - the pack marks it force_input, so it appears as an input socket and nothing else. That's deliberate (arrays are supposed to come from a producer), but it's the number one "why can't I type anything" moment with these nodes. Feed it from πŸ“‹ Array From Text, πŸ“‚ List Files, πŸ“‚ Read File, or a text node.

    Of the booleans, Remove Empty and Trim Items are on by default and should probably stay that way. Remove Duplicates is off, which is the right call - silently deleting user data is worse than the occasional dupe.

    Two outputs: Array (the cleaned string, wired onward to Slice, For Each, To Text, or straight into a prompt encoder) and Count (an INT of how many items survived). Count is the underrated one - it's how you tell a filter that worked from a filter that ate everything.

    Installing it

    ComfyUI Manager is the path of least resistance: Extensions β†’ Node Pack β†’ search "Honda Nodes" β†’ Install β†’ restart. The pack is in the official registry under publisher avaray.

    Manually:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    

    The pack also ships an install.py that downloads two CLI binaries (jq and ime) into honda-nodes/bin. Array nodes don't need either of them, but the JSON and metadata nodes do, so run it anyway while you're here:

    # ComfyUI portable on Windows
    ..\..\..\python_embeded\python.exe install.py
    # Linux / macOS / venv
    python install.py
    

    One real requirement: this pack is written entirely against ComfyUI's V3 node schema (comfy_api.latest) and declares requires-comfyui >= 0.38.0. On an older install you get zero nodes and no error worth reading.

    Where it goes wrong

    "I set it up and nothing happened." Array Filter is not an output node, and ComfyUI only executes what an output node needs - it works backwards from Save Image, Preview Image and friends. A filter dangling into nowhere is never run, so the Count you were watching never updates. Terminate the chain in something: a πŸ”€ Text Preview, πŸ“‘ JSON Preview, πŸ› οΈ Print to Console, or a save node further down.

    Everything vanished. A pattern that matches nothing returns an empty Array and Count = 0, quietly. If you're filtering and the count drops to zero, the pattern is wrong, not the node. Blank means no filter; a glob means filter hard.

    Stale results. Because the string is the input, editing the upstream text node changes the cache key and re-runs - but if you're pulling from a file, the file changing does not. If a re-run gives you yesterday's file list, that's the engine's cache, not the filter.

    Category⚑️ Honda Nodes/πŸ“‹ Array

    Inputs (6)

    NameTypeDefaultDescription
    arraySTRINGNewline-separated array string.
    remove_emptyBOOLEANtrueRemove empty lines from the array.
    remove_duplicatesBOOLEANfalseRemove duplicate items, keeping the first occurrence.
    patternSTRINGOptional glob pattern. Items matching the pattern are kept (or removed if Invert Pattern is enabled).
    invert_patternBOOLEANfalseIf enabled, items matching the pattern are removed instead of kept.
    trim_itemsBOOLEANtrueStrip leading and trailing whitespace from each item.

    Outputs (2)

    NameTypeDescription
    ArraySTRINGβ€”
    CountINTβ€”