Nodes/ComfyUI-JNodes/JNodes_AddOrSetMetaDataKey
ComfyUI Node

JNodes_AddOrSetMetaDataKey

Stamp any custom key/value into your image metadata

By JaredTherriault·Created 3 years ago·Updated about a month ago· 91
JNodes_AddOrSetMetaDataKey
    • BOOLEAN
    key
    value

    This is the general-purpose version of JNodes' metadata writers. Where Set Positive/Negative Prompt In MetaData handle the two standard A1111 fields, Add Or Set MetaData Key lets you write any key you want with any value. Want to record which LoRA stack you used, the name of the preset, a project tag, the sampler settings as a note, the phase of the moon - you give it a key and a value, and it goes into the image's png_info. If the key already exists it overwrites it; if it doesn't, it adds it. Hence "add or set."

    The reason this is useful is organization at scale. If you generate a lot and later want to search or sort by something ComfyUI doesn't record on its own, the trick is to stamp it in at generation time. JNodes' ImageDrawer can search image metadata, and A1111-style viewers read these keys, so a custom key you write now is a filter you can use later.

    How it works

    It's a straightforward metadata write. You provide a key and a value; when the graph runs, that pair is inserted into the current generation's png_info and gets embedded when the image is saved. It doesn't transform anything or affect the image the sampler makes - it's pure bookkeeping on the metadata side. Chain several of these to stamp several keys, or feed values from other nodes (a parameter reader, a filename cleaner, a selector's string output) to record computed values rather than hand-typed ones.

    The inputs and outputs that matter

    • key - the metadata key name to write. Single-line. Pick something you'll remember and can search on later.
    • value - the value to store under that key. Multiline, so long notes are fine.

    The output is a BOOLEAN confirmation flag, handy for chaining one metadata write after another or gating a later step. It's an output node, so it executes and does the write even if nothing consumes that boolean.

    How to install it

    ComfyUI Manager, search JNodes, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JaredTherriault/ComfyUI-JNodes
    pip install -r ComfyUI-JNodes/requirements.txt
    

    No models to download.

    Common issues & troubleshooting

    The key isn't in my file. Metadata is embedded at save time, so this has to be in the same graph that saves the image, and the saver has to preserve png_info. JNodes' own save nodes do; some other savers throw metadata away. Verify with a metadata viewer after saving.

    Overwriting when you meant to keep both. The node sets - same key twice means the second write wins. If you want two values, use two distinct key names.

    Wiring a non-text value in. The value field is a string. If you're feeding it a number or another type from an upstream node, convert it to a string first (the pack's AnyToString node does exactly this) so it records cleanly.

    Search isn't finding it. Keys are matched by name. If you're searching in ImageDrawer or an A1111 viewer and coming up empty, confirm the key you wrote matches the key you're searching, spelling and case included.

    Categorysd

    Inputs (2)

    NameTypeDefaultDescription
    keySTRING
    valueSTRING

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN