Nodes/comfyui-mudknight-utils/Character Replace
ComfyUI Node

Character Replace

Swap known character tags for their full definitions, keep the rest

By mudknight·Created 8 months ago·Updated 2 months ago· 1
Character Replace
    • prompt
    • character_pos
    • character_neg
    input_tags

    Character Replace is the sibling of Character Preset with a different trick up its sleeve. Character Preset hands you a whole character from a dropdown; this one takes a comma-separated string of tags, splits it, and expands any tag that matches an entry in the same characters.jsonc config into that character's full tag set - while leaving unmatched tags alone and passing them straight through.

    Think of it as a macro expander for your prompt. You type a short tag list like hatsune miku, standing, concert, stage, the node looks up hatsune miku in the config and replaces it with the full definition you stored (character tags, outfit, negatives), and outputs the result as three separate strings: the remaining prompt, the character's positive tags, and the character's negative tags.

    How it works

    • Input: input_tags - a multiline, comma-separated tag string.
    • Outputs: prompt (tags that matched nothing - the scene, action, everything else), character_pos (the character's positive tags, pulled from the config), and character_neg (the character's negatives).

    Two special tags make it flexible: if your input contains the bare word top or bottom, the node toggles including that part of the character's outfit definition. So 1girl, top, sitting on bench gives you the character with her top but no bottom, and the outfit tags land in character_pos rather than the prompt. It's a small DSL, but it's genuinely handy for batch jobs where you vary the outfit per render.

    The config

    Same file as Character Preset: custom_nodes/comfyui-mudknight-utils/config/characters.jsonc, same JSONC format, same auto-reload on modification. If a tag isn't in the config it's just passed through to prompt - which is the node's real strength: you can run arbitrary tag strings through it and only the characters you've defined get expanded.

    Installing it

    In mudknight-utils - ComfyUI Manager (search comfyui-mudknight-utils) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mudknight/comfyui-mudknight-utils
    

    No extra dependencies.

    Where people get burned

    The main trap is expecting partial matches. This is exact-match tag replacement - miku won't match an entry keyed hatsune miku, and top is reserved as a toggle, so a character literally tagged top won't expand. If you're building a batch workflow around it, keep the config keys identical to the tags you type. And because matched tags are pulled out of the prompt into character_pos, wire all three outputs into your prompt or you'll quietly drop the character's identity. If your prompt builder concatenates just the prompt output, you'll get a person-less scene and a very confused render.

    Categorymudknight/presets

    Inputs (1)

    NameTypeDefaultDescription
    input_tagsSTRING

    Outputs (3)

    NameTypeDescription
    promptSTRING
    character_posSTRING
    character_negSTRING