Nodes/ComfyUI-TinyBee/File Metadata
ComfyUI Node

File Metadata

Read the JSON Living Next to Your Image

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
File Metadata
    • metadata
    image_path

    A common organizational pattern in ComfyUI is keeping metadata in a JSON file next to the thing it describes - a prompt, a seed, a score, sidecar data for a batch of images. The problem is ComfyUI has no built-in way to say "give me the JSON that lives beside this path." File Metadata is that reader: point it at an image path, and it loads the companion JSON files for that image and returns their merged contents as an object. It's a small node, but it's the on-ramp for any workflow where data lives on disk alongside images rather than inside ComfyUI's own format.

    How it works

    One input, one output:

    • image_path - the path to an image file.
    • metadata - the merged JSON as an OBJECT (empty dict {} if nothing's found or the path is blank).

    The lookup convention is the real spec here. Given an image at some/folder/img_001.png, the node looks for two files in the same directory:

    1. <folder-name>-defaults.json - i.e., some/folder/folder-defaults.json. Lower priority; meant for settings that apply to everything in that folder.
    2. <image-basename>-meta.json - i.e., some/folder/img_001-meta.json. Higher priority; per-image metadata.

    Both are merged into the result, with the per-image file overriding the defaults where keys collide. Files are read only if they exist; a missing one is skipped, and if the JSON is malformed you get a console error for that file while the other still loads. Only the meta file naming depends on the image itself, so the convention is worth knowing before you build a folder of data around it.

    A quiet detail: the node's change detection keys on the image path plus the modification times of both JSON files - so if you edit img_001-meta.json and re-queue, you get fresh data without ComfyUI stubbornly caching the old read. For a metadata reader that's exactly the behavior you want.

    Where you'd actually use it

    • Batch post-processing: each generated image has a -meta.json sidecar; loop the list, read each one's metadata, and route the run by its contents.
    • Folder-wide defaults: a single folder-defaults.json that applies to every image in the folder, overridden per-image when needed.
    • Interop with the property pipeline: the OBJECT output feeds Dictionary Lookup, which then feeds the property encoders - the pack's metadata story plugs together end to end.

    Installing it

    Part of ComfyUI-TinyBee under 🐝TinyBee/Dictionaries:

    1. ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee" → Install, then restart ComfyUI.
    cd ComfyUI/custom_nodes
    git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
    

    Restart. No models; the dependencies are os, json, and os.path.getmtime - none of the pack's requirements.txt entries (pillow, jsonata) get involved.

    Gotchas

    The filename convention is the whole game: it only finds folder-defaults.json and imagebasename-meta.json, in that exact arrangement. Your own naming scheme won't be found, and there's no input to remap it - so if you're bringing in a dataset with differently-named sidecars, rename or pre-process first. Blank or empty paths return {} rather than erroring, which is friendly but means a typo'd path is silent. And remember the output is an object, so pull fields out with Dictionary Lookup or similar - you can't wire an object into a text box directly.

    Category🐝TinyBee/Dictionaries

    Inputs (1)

    NameTypeDefaultDescription
    image_pathSTRING

    Outputs (1)

    NameTypeDescription
    metadataOBJECT