Files
ComfyUI-JSON-Dynamic/README.md
Ethanfel 35d73176d8 Document segment/batch_data lookup with SVG diagram
Explains flat vs batch JSON, segment lookup logic (match by
sequence_number field, fallback to index, clamping), and per-segment
key differences.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 20:01:41 +01:00

10 KiB

{ Dynamic } ComfyUI JSON Dynamic Loader Auto-discover JSON keys as typed output slots

License ComfyUI

A single ComfyUI node that reads any JSON file and automatically creates output slots for every key it finds. No hardcoded outputs — when your JSON structure changes, just click Refresh.

Features

  • Auto-discovery — reads JSON keys and exposes them as named outputs
  • Type detectionINT, FLOAT, STRING types with colored connectors
  • Batch supportsequence_number input for batch_data arrays
  • Connection-safe refresh — adding new keys preserves existing links
  • Workflow persistence — keys, types, and connections survive save/reload

Installation

ComfyUI Manager

Search for JSON Dynamic Loader in the ComfyUI Manager registry.

Manual

cd ComfyUI/custom_nodes/
git clone https://github.com/ethanfel/ComfyUI-JSON-Dynamic.git
# Restart ComfyUI

Usage

  1. Add JSON Dynamic Loader node to your workflow
  2. Enter a json_path and sequence_number
  3. Click Refresh Outputs
  4. Outputs appear named after your JSON keys with correct types
  5. Connect to downstream nodes

JSON Dynamic Loader json_path: /data/prompt.json sequence_number: 1 Refresh Outputs general_prompt negative seed flf camera KSampler positive seed

Type Handling

JSON type Output type Connector
42 (integer) INT Blue
3.14 (float) FLOAT Teal
"hello" (string) STRING Pink
true / false STRING ("true" / "false") Pink

JSON Format

Flat JSON (single segment)

For simple use cases, the node reads keys directly from the root object. The sequence_number input is ignored.

{
  "general_prompt": "A cinematic scene...",
  "seed": 42,
  "flf": 0.5,
  "camera": "pan_left"
}

Batch JSON (multiple segments)

For multi-shot workflows, wrap entries in a batch_data array. Each entry is a segment representing one shot/scene with its own settings. The sequence_number input selects which segment to read.

{
  "batch_data": [
    {
      "sequence_number": 1,
      "general_prompt": "Wide establishing shot of a city",
      "seed": 42,
      "camera": "static",
      "flf": 0.0
    },
    {
      "sequence_number": 2,
      "general_prompt": "Close-up of the protagonist",
      "seed": 108,
      "camera": "pan_left",
      "flf": 0.5,
      "my_custom_key": "only on this segment"
    },
    {
      "sequence_number": 3,
      "general_prompt": "Aerial drone shot over rooftops",
      "seed": 77,
      "camera": "zoom_in",
      "flf": 0.8
    }
  ]
}

Segment lookup

The node resolves which segment to read using this logic:

  1. Match by sequence_number field — scans batch_data for an entry whose sequence_number matches the input
  2. Fallback to array index — if no match is found, uses sequence_number - 1 as the array index (clamped to bounds)
  3. No batch_data — reads keys from the root object directly

This means segments don't need to be in order and can have gaps (e.g. 1, 5, 10). Each segment can have different keys — click Refresh Outputs after changing sequence_number if the keys differ between segments.

batch_data[] seq 1: city, seed=42 camera=static, flf=0.0 seq 2: close-up, seed=108 camera=pan_left, flf=0.5 seq 3: aerial, seed=77 camera=zoom_in, flf=0.8 seq=2 JSON Dynamic Loader general_prompt seed camera "Close-up of the protagonist" 108 "pan_left"

License

Apache 2.0