<p align="center">
<img src="assets/banner.svg" alt="ComfyUI JSON Dynamic Loader banner" />
ComfyUI-JSON-Dynamic Introduction
ComfyUI-JSON-Dynamic is a collection of utility nodes for ComfyUI. Its main node, JSON Dynamic Loader, turns values in a JSON file into named outputs you can connect to the rest of your workflow. The collection also includes nodes for working with text and file paths, plus a way to send a generated image to a LoadImage node.
For an AI art workflow, a JSON file can act like a shot list: it can hold prompts, seeds, camera directions, and other settings for one scene or many. Instead of copying each value into nodes by hand, you can select a scene and connect its values where you need them. The loader adapts its outputs to the keys in your file, so you can use your own names for settings.
How ComfyUI-JSON-Dynamic Works
JSON is a text format for storing named values. Think of each name, or key, as a label on a setting. In this example, general_prompt labels the prompt text, while seed labels a whole number:
{
"general_prompt": "A cinematic scene at sunrise",
"seed": 42,
"flf": 0.5
}
When you give JSON Dynamic Loader the file’s json_path and click Refresh Outputs, it reads the keys and creates outputs with matching names. You can then connect general_prompt to a node that accepts text, seed to one that accepts an integer, and flf to one that accepts a decimal value.
A file can also contain several scenes in a batch_data array. Each entry is a segment with its own settings. The loader uses its sequence_number input to choose which segment supplies the values. This lets one workflow draw settings from different shots without requiring a separate loader setup for every shot.
The extension’s other nodes handle smaller tasks around that workflow: assembling paths, formatting or extracting text, choosing between values, and passing a previewed image into LoadImage.
ComfyUI-JSON-Dynamic Features
Dynamic JSON outputs
Add JSON Dynamic Loader, enter a json_path and sequence_number, then click Refresh Outputs. The node creates an output for each key it finds in the selected JSON object. Connect those outputs to nodes that use the values.
<p align="center">
<img src="assets/node-diagram.svg" alt="JSON Dynamic Loader outputs connected to a ComfyUI workflow" />
The loader identifies these value types:
| Value in JSON | Output type | Connector color |
|---|---|---|
42 | INT (whole number) | Blue |
3.14 | FLOAT (decimal number) | Teal |
"hello" | STRING (text) | Pink |
true or false | STRING containing "true" or "false" | Pink |
The distinction matters when connecting nodes: a numeric seed, for example, can be used as an integer output, while a prompt is provided as text. JSON true/false values become the text "true" or "false", not a BOOLEAN output.
Flat JSON: For a single scene, put keys directly in the root object. The loader reads those keys and ignores sequence_number.
{
"general_prompt": "A cinematic scene...",
"seed": 42,
"flf": 0.5,
"camera": "pan_left"
}
Batch JSON: For multiple scenes, place objects inside batch_data. Set the node’s sequence_number to select a segment:
{
"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
}
]
}
The loader first looks for an entry whose own sequence_number matches the input. If it finds none, it uses the input minus one as a position in the array, keeping that position within the array’s bounds. Because an explicit match takes priority, segments do not have to appear in numerical order; their numbers can also have gaps such as 1, 5, and 10.
Segments may contain different keys. After changing sequence_number, click Refresh Outputs if the new segment has different keys. Refreshing to add keys preserves existing connections, and the extension retains keys, types, and connections when you save and reopen a workflow.
<p align="center">
<img src="assets/segment-lookup.svg" alt="Diagram showing how sequence_number selects a batch_data segment" />
String and path utilities
These four nodes help you prepare values for other parts of a workflow.
| Node | What it does | Example use |
|---|---|---|
Path Join (utils/path) | Joins one required path segment and up to five optional segments into a normalized path. Outputs path as text. | Combine a folder, project name, and filename. |
String Format (utils/string) | Fills placeholders in a template using up to eight connected values, v0–v7. Outputs string. | Use {0}/{1:04d} to place a value in a path and display a number with four digits. |
String Extract (utils/string) | Pulls out part of a string using one of three modes. Outputs result, dirname, basename, and extension as text. | Take one part of a separated label or identify a file’s extension. |
String Switch (utils/string) | Chooses a value based on a required BOOLEAN condition. Outputs result. | Select one of two prompts or paths according to a condition. |
String Extract offers three modes: split_take splits text at a delimiter and takes a part by index (including a negative index); between takes text between two delimiters; and filename_parts separates a path into directory name, base name, and extension.
For String Switch, connect values to on_true and on_false when you have them. If the selected side has no connected value, the node uses its corresponding default_true or default_false text widget instead. Connected values take priority over those defaults.
Preview to Load Image
Preview to Load Image (utils/image) displays an image like ComfyUI’s PreviewImage node and also saves a PNG copy in ComfyUI’s input/ folder. This gives you a way to place a generated result into a LoadImage node for another part of your workflow.
Connect an IMAGE to images. The optional filename text sets the saved name without an extension; its default is preview. You can also connect a MASK, which the node embeds in the PNG’s alpha channel so LoadImage can output it as a mask.
- Run the node to display a temporary preview and save a copy as
input/{filename}.png. - Enter the target LoadImage node’s ID in
load_image_node_id. - Click Send to Load Image. The target node’s image selector updates to the saved file without a restart.
Troubleshooting ComfyUI-JSON-Dynamic
The JSON outputs do not show the keys you expect
- Check that
json_pathpoints to the JSON file you intend to use. - If the file contains
batch_data, check which segment the currentsequence_numberselects. - Click Refresh Outputs, especially after editing the file or switching to a segment with different keys.
A different batch segment is selected
- Check whether any entry has a
sequence_numberfield matching the node input. An explicit match takes priority over array position. - If there is no match, remember that the loader uses
sequence_number - 1as an array position, clamped to the available entries. - Give segments explicit
sequence_numberfields when you want their selection to remain clear even if you reorder the array.
A true/false value does not connect to a BOOLEAN input
The loader outputs JSON true and false as the strings "true" and "false". Its documented type handling does not provide a BOOLEAN output for those values.
An image does not appear in the target LoadImage node
- Run Preview to Load Image so it saves the PNG copy.
- Check that
load_image_node_idcontains the ID of the intended LoadImage node. - Click Send to Load Image and check that node’s image selector.
A mask is missing from the loaded image
Check that a MASK is connected to Preview to Load Image when it runs. The node embeds a connected mask in the saved PNG’s alpha channel for LoadImage to output.
Frequently asked questions
Do I need a batch_data array for one image or scene?
No. Put your keys in a flat JSON object. In that format, sequence_number is ignored.
Can different scenes have different settings?
Yes. Each batch_data entry can have its own keys. Refresh the outputs after selecting a segment whose keys differ.
Will refreshing remove connections I already made?
The extension describes its refresh as connection-safe: adding new keys preserves existing links.
Do I have to restart ComfyUI after sending an image to LoadImage?
No. Send to Load Image updates the target image selector immediately.
Learn More about ComfyUI-JSON-Dynamic
The extension repository contains the project files. The diagrams above provide visual examples of connecting the loader and selecting batch segments.
ComfyUI-JSON-Dynamic is provided under the Apache 2.0 license.
