Nodes/ComfyUI-OllamaPromptsGeneratorTlant/Extract JSON from PNG (Tlant)
ComfyUI Node

Extract JSON from PNG (Tlant)

Pull a ComfyUI Workflow Out of Any PNG's Metadata

By Tlant·Created 2 years ago·Updated 5 months ago· 2
Extract JSON from PNG (Tlant)
    • workflow_json
    • error
    image_path

    ComfyUI's whole sharing culture runs on one trick: the workflow JSON lives inside the output PNG's metadata, so "workflow included" means the recipe travels with the picture. Normally you recover that by dragging the PNG back onto the canvas. This node does it programmatically - give it a path to a PNG and it returns the embedded workflow (or prompt) JSON as a string, ready to be inspected, parsed, or piped into another node mid-graph.

    How it works

    It opens the image with PIL and reads its text chunks, checking fields in priority order: workflow first (ComfyUI's complete graph with positions and layout), then prompt (the leaner execution structure). Either can come back as a dict or as a JSON string; both are handled, and the result is serialized to a compact JSON string with ensure_ascii=False so non-English prompt text survives. If neither field exists, it lists every metadata key it did find in the error output - which is genuinely helpful when a file was saved by a tool that used an unusual chunk name.

    Inputs and outputs

    One input, image_path (a string; the placeholder suggests /path/to/image.png). Two outputs:

    • workflow_json - the extracted workflow/prompt as a STRING.
    • error - empty on success, populated with a readable message on failure.

    Install

    It's part of the Tlant pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Tlant/ComfyUI-OllamaPromptsGeneratorTlant
    

    restart, done. Or via ComfyUI Manager ("Extract JSON from PNG (Tlant)").

    Where people get burned

    • It only reads what's there. PNGs stripped of metadata (resaved by some editors, or generated by tools that don't embed) simply won't have workflow or prompt - you'll get an error naming the available keys. Don't expect magic from a bare image.
    • workflow vs prompt matter downstream. workflow is the full graph with layout (what you drag onto canvas); prompt is the lean execution map. Both are valid JSON but they parse differently. If you're feeding the output into ExtractPromptFromJsonTlant to dig out a prompt, either can work, but the field paths will differ.
    • Extension isn't enforced. It warns (but doesn't refuse) if the path isn't a .png, then tries to read anyway - fine for a JPEG with metadata, but don't count on it.
    • Big output, small widget. A full workflow can be tens of kilobytes. It's a string, so it works, but you usually want to connect it to a processing node rather than stare at it in a widget.

    Pair it with ExtractPromptFromJsonTlant and you've got a programmatic pipeline: PNG in, prompt out, no dragging files around.

    Categorytlant/utils

    Inputs (1)

    NameTypeDefaultDescription
    image_pathSTRING

    Outputs (2)

    NameTypeDescription
    workflow_jsonSTRING
    errorSTRING