ComfyUI Node

Text Hash

A short, stable fingerprint for any prompt

By hustille·Created 3 years ago·Updated 2 years ago· 5
Text Hash
    • hash
    text
    length8

    Somewhere between "random number" and "full sha256" there's a niche for a short, deterministic fingerprint of a piece of text. Text Hash fills it: feed it any string, get back the first N characters of that text's sha256 digest, always the same for the same input. Same prompt in, same hash out, on any machine, forever. That determinism is the entire point - you're building an identifier, not a surprise.

    It's a one-trick node, but the trick slots into a real habit. In the author's example workflow, filename prefixes are built as prompt hash – style – seed – model – sampler settings, which is exactly the "tell me what made this image by looking at its name" pattern the pack is trying to recreate from A1111.

    How it works

    One line of Python under the hood: hashlib.sha256(text.encode()).hexdigest()[:length]. The text is hashed as the literal bytes you feed it, the hex digest is truncated to length characters, and that's your output.

    The inputs

    • text - multiline, and marked forceInput, so it can be driven by a wire from any other string-producing node. Hash a prompt, a filename prefix, or a full workflow description.
    • length - how many hex characters to keep, from 1 to 40, default 8.

    Output is a single STRING named hash.

    Where you'd use it

    • Filenames. Hash your prompt and bake it into the output prefix, so two images that look the same but came from different prompts get different names.
    • Change detection. Hash a prompt before and after edits - if the hash moved, the text moved.
    • Grouping. Run the same prompt through different settings and the hash lets you sort results by prompt at a glance.

    Gotchas

    • 8 hex characters is 32 bits of entropy. That's plenty for casual filename use, but if you're hashing tens of thousands of distinct strings, collisions become thinkable - bump length toward 12–16 and stop worrying.
    • It hashes the literal text, whitespace included. "cat" and "cat " hash differently, so trailing spaces will quietly fork your filenames.
    • It's a one-way fingerprint. You can't recover the prompt from the hash, so don't use it as your only record of what ran.

    Install

    Via ComfyUI Manager, search "hus' utils" (pack title: hus' utils for ComfyUI). Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hustille/ComfyUI_hus_utils
    

    Restart ComfyUI. No requirements.txt, no pip step, no model downloads - pure Python standard library, so nothing to break.

    Categoryutils/hus

    Inputs (2)

    NameTypeDefaultDescription
    textSTRING
    lengthINT81–40

    Outputs (1)

    NameTypeDescription
    hashSTRING