Nodes/YG Custom Nodes/JSON To Image Generation
ComfyUI Node

JSON To Image Generation

Drive a whole batch from a JSON file of prompts

By mallikarjunaraokoliparthi·Created 2 months ago·Updated about a month ago· 0
JSON To Image Generation
    • prompt
    • output_path
    • job_id
    • current_index
    • total_count
    • is_last
    json_file
    job_idmy_json_job
    json_path_override

    If you've ever had a spreadsheet of prompts that each need to become an image, you know the manual way: paste, generate, save, repeat. YG JSON Prompt Loader ("JSON To Image Generation") automates the whole loop by reading a JSON or JSONL file where every entry is one job - a prompt plus an output_path saying where that image should end up. Each queue run hands you the next entry's prompt, so you can set the queue running and walk away.

    How it works

    Drop a .json or .jsonl file into ComfyUI's input folder, and it appears in the json_file dropdown. The file can be a plain JSON array of objects, or JSONL (one object per line) - the node sniffs which it is. Each object should look like:

    {"prompt": "a devotional poster, warm tones", "output_path": "images/devotional/001.jpg"}
    

    output_path is optional; if missing, it falls back to <id>.png or image.png. On each queue run the node emits the next entry and advances an index (the IS_CHANGED NaN trick keeps it re-executing every run). When the last entry is served, is_last flips true. The file's folder structure lives inside each output_path, which is the whole trick of the paired downloader node.

    The natural wiring the author had in mind:

    YG JSON Prompt Loader → [any image generator] → YG JSON Image Downloader
    

    The inputs and outputs that matter

    • json_file - the dropdown of JSON files in your input folder. Not seeing yours? Drop it in and restart, or use the override below.
    • json_path_override - paste a full or relative path to a JSON file and it bypasses the dropdown entirely. Useful when your file lives elsewhere or changes often.
    • job_id - must match the job_id on your YG JSON Image Downloader. Get this wrong and nothing breaks loudly, it just silently mismatches jobs.

    Outputs: prompt (feed it to your text encoder or generator), output_path (feed it to the downloader), plus job_id, current_index, total_count, and is_last for batch bookkeeping.

    Installing it

    Part of comfyui_yg_nodes (MIT, "YG Custom Nodes" v1.0.4 by Mallikarjuna Rao Koliparthi). No extra Python dependencies. Install via ComfyUI Manager (search comfyui_yg_nodes) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mallikarjunaraokoliparthi/comfyui_yg_nodes.git
    

    Restart ComfyUI; it's under YG Custom Nodes.

    Where people get burned

    The state is in-memory and keyed by job_id: restart ComfyUI and the loader starts back at entry zero, so a 500-line JSON that was halfway through will restart from the beginning - and rerun the first 250 images unless you trim the file or change job_id. Also, "No entries found" usually means your JSON is neither an array nor valid JSONL - check for a stray trailing comma or a JSON object without brackets. And the loader itself never re-reads a changed file mid-job for the same job_id; edit the file, restart (or use a fresh job_id). For prompt-driven batch generation at scale - exactly the "Nano Banana Pro poster line" use case it was built for - this is a solid, dependency-free way to get there.

    CategoryYG Custom Nodes

    Inputs (3)

    NameTypeDefaultDescription
    json_fileCOMBO1 options: (No .json/.jsonl files in input folder)
    job_idSTRINGmy_json_jobMust match the job_id in YG JSON Image Downloader.
    json_path_overrideoptSTRINGPaste a full or relative path to a .json/.jsonl file. If set, this overrides the json_file dropdown.

    Outputs (6)

    NameTypeDescription
    promptSTRING
    output_pathSTRING
    job_idSTRING
    current_indexINT
    total_countINT
    is_lastBOOLEAN