Nodes/ComfyUI-MDSNodes/MetaData Append (Switch)
ComfyUI Node

MetaData Append (Switch)

Tag a run conditionally, without a second graph

By MarwanDSAI·Created 3 months ago·Updated about 15 hours ago· 3
MetaData Append (Switch)
    • METADATA
    ◄switchtrue►
    ◄keymy_key►
    ◄value_true►
    ◄value_false►
    ◄metadata►

    There are two ways to record what a run was: trust the embedded workflow, or write your own field into the metadata. This is the second kind - a key/value pair you add deliberately, chosen by a boolean, so the record stays truthful when a branch didn't run.

    What it's for

    Consider a model comparison where each image is generated with an optional refiner. The embedded ComfyUI graph already tells you everything, in the sense that it's all in there - as a JSON blob nobody wants to parse at 2 a.m. What you want is a string you can read: Model [juggernautXL]; Refiner [on]; Prompt_Slot [3].

    The reasoning is the same one behind swapping in a custom save node if you post to CivitAI: the destination reads flat parameter strings well and node graphs not at all. A tidy Key [Value] line is legible to a human, cheap to generate, and survives being copied into a filename or a sidecar.

    The switch is the part that earns the node its place. You don't want Refiner [off] hardcoded - you want the field appended only when the refiner branch actually ran, and skipped when it didn't. The node does that: it appends the chosen value if that value is non-empty, and returns the metadata untouched if it's blank.

    How it works

    The metadata format the whole family uses is a single string:

    Key1 [Value1]; Key2 [Value2]; Key3 [Value3]
    

    Inputs:

    • switch - BOOLEAN, default on. True appends value_true, False appends value_false.
    • key - single-line string, default my_key. That's the field name.
    • value_true / value_false - the two candidate values, single-line strings.
    • metadata (optional) - the incoming chain. Disconnected means "start from empty."

    Output: METADATA (STRING), the combined string.

    The behaviour worth knowing precisely, because it's the author being careful: the chosen value is stripped, and if it's empty the node returns the input unchanged - no dangling Key [] in your line. It also only prepends the ; separator when there's already content, so the first append doesn't start with a stray delimiter.

    Chain them: one node per field, each feeding the next, the last one feeding whatever consumes metadata - MetaData Convert to EXTRA_METADATA from the same pack, a save node that accepts a metadata string, or just a text preview while you're debugging.

    Installing it

    ComfyUI-MDSNodes by MarwanDSAI. ComfyUI Manager: search ComfyUI-MDSNodes or MDSNodes, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MarwanDSAI/comfyui-mdsnodes
    # restart ComfyUI
    

    No pip step and nothing to download - the repo's requirements.txt is empty and the README says the pack runs on stock ComfyUI dependencies.

    Search MetaData Append (Switch), category MDSNodes/MetaData. The plain Metadata Append is the same node without the switch, if you always want the field.

    Common issues

    The field vanished from the output. The chosen value was empty. That's the skip rule working - if you want a field that says nothing happened, put a literal word in the value box (off, none) and switch on that, instead of relying on a blank.

    Semicolons in your value broke the parse. The format uses ; as its delimiter and, notably, brackets as its value markers. A value containing ; or ] will confuse anything downstream that splits on them. Keep values to short tokens.

    metadata shows a red required-input marker. In the source it's declared optional, so a disconnected socket is legal - but the field is a forced input, so you can't type the starting string into the node. Seed the chain with Empty from this pack, or with the output of a first MetaData Append.

    Nothing shows up in the saved PNG. These strings don't write themselves into files. They become workflow metadata only if you land them somewhere that serialises them - a save node that accepts a metadata input, or the pack's EXTRA_METADATA converter feeding one. Otherwise you've built a very tidy string that nobody reads.

    CategoryMDSNodes/MetaData

    Inputs (5)

    NameTypeDefaultDescription
    switchBOOLEANtrueTrue appends value_true, False appends value_false.
    keySTRINGmy_keyThe key name you type into the textbox.
    value_trueSTRINGThe text value to insert when the switch is True.
    value_falseSTRINGThe text value to insert when the switch is False.
    metadataoptSTRINGThe original base string. If disconnected, treated as empty.

    Outputs (1)

    NameTypeDescription
    METADATASTRINGThe combined output string with the appended key and value.