Nodes/honda-nodes/🏷️ Convert Metadata Format
ComfyUI Node

🏷️ Convert Metadata Format

PngText vs UserComment, translated before it's lost

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
🏷️ Convert Metadata Format
    • Converted Metadata
    β—„metadata{}β–Ί
    β—„target_formatβ–Ύβ–Ί

    The problem it solves is a file-format problem

    Metadata in ComfyUI isn't one thing. A PNG carries PNG text chunks (tEXt/iTXt) - that's where the workflow and prompt blobs live, and it's why dragging a PNG onto the canvas rebuilds the graph. JPEG and WebP have no such chunks; the only place a flat parameter string fits is EXIF's UserComment field. That's not a preference, it's the container spec, and it explains the entire existence of this node.

    The pack's metadata layer - its integration with the author's own ime (image-metadata-editor) CLI - models this explicitly. Metadata JSON has a custom object, and inside it either a PngText dictionary (for PNG) or a UserComment dictionary (for JPEG/WebP). Convert Metadata Format translates one into the other so you don't ship a payload the target container will drop on the floor.

    The everyday scenario: you extracted metadata from a PNG, edited it (deleted a tag, added a field), and now you want to save the result as a JPEG or WebP. Without this node the PngText shape is meaningless to a JPEG writer. With it, the keys get folded into UserComment and survive.

    How it works

    It parses your metadata JSON, looks at custom, and moves things around:

    • Target png: any UserComment is popped into PngText, merged if PngText is already a dict.
    • Target jpg or webp: any PngText is popped into UserComment, merged the same way, since both formats use the same single comment field.

    Everything else in the JSON passes through untouched - top-level keys, exif, custom keys you added. The output is a compact JSON string with ensure_ascii=False, so non-ASCII text (Japanese tags, emoji in a prompt) isn't mangled into escapes.

    One design decision you should know about: on merge collisions the incoming side wins. Converting PNG β†’ jpg does user_comment.update(png_text), so a PngText key that shares a name with an existing UserComment key overwrites it. If you've hand-edited a UserComment and then convert, check for name clashes.

    Inputs and output

    Metadata (JSON) is a multiline STRING, default {}. This is the wire format the whole metadata group speaks, which means it comes out of 🏷️ Extract Metadata (via a JSON step) or out of πŸ“‘ JSON Set Key / πŸ“‘ JSON Delete Key / πŸ“‘ JSON Merge. It is not the image itself - this node never touches pixels.

    Target Format is a combo: png, jpg, webp. Pick the format you're actually going to save. Picking png when you save a JPEG is how you end up with metadata the file silently doesn't keep.

    Output is a single Converted Metadata STRING, ready to hand to 🏷️ Write Metadata or the pack's save image node - both of which take a format decision of their own, so keep the two consistent.

    Frustrating but important: invalid JSON produces no error. The function catches the decode failure and returns your input unchanged. If your output looks identical to your input, the first thing to check is whether the input parses at all - run it through πŸ“‘ JSON Validate or πŸ“‘ JSON Preview upstream.

    Install

    Manager: Extensions β†’ Node Pack β†’ search "Honda Nodes" β†’ Install β†’ restart. Manual:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py    # ComfyUI's python; portable Windows: ..\..\..\python_embeded\python.exe install.py
    

    This node is pure Python - no binaries needed. But its neighbours in the metadata family (the pack's extract and write nodes) shell out to the ime binary that install.py puts in honda-nodes/bin, and the JSON nodes need jq from the same place. Run the installer once and the whole pack works. ComfyUI 0.38.0+ required: the pack is V3-schema only.

    Common issues

    Output identical to input. Either the JSON didn't parse (silent, see above) or there was nothing to translate - converting a PngText payload to png is a no-op, correctly.

    Metadata doesn't show up in the saved file. Check the container's limits before blaming the node: PNG keeps text chunks and loses EXIF comment fields in some tools; JPEG and WebP can't hold PNG chunks at all. Convert to the format you're saving, and save with a writer that actually writes metadata.

    "Why is my workflow gone from this JPEG?" Because JPEG has no tEXt chunks. The ComfyUI graph only round-trips in PNG. Converted metadata preserves your fields, not the whole graph-in-image convention - if you want to share a loadable workflow, keep the PNG.

    Category⚑️ Honda Nodes/🏷️ Metadata

    Inputs (2)

    NameTypeDefaultDescription
    metadataSTRING{}The input metadata JSON string to be converted.
    target_formatCOMBOThe image format you intend to save this metadata into.

    Outputs (1)

    NameTypeDescription
    Converted MetadataSTRINGβ€”