JSON Prompt Combinator
Generate every prompt combination from one JSON blob
- json_input
- ui_widget
- string
- string_list
- count
- json
If you've ever set up a batch-generation run by hand-copying prompt variations, this node is here to end that. LF_JSONPromptCombinator takes a hierarchical JSON of prompt parts and generates every sensible combination of them - the Cartesian product of your variations - as ready-to-use prompt strings. It's the combinator for people who think of a batch as a grid of choices rather than a list of copy-pastes.
The shape is simple: your JSON defines the pieces, and the node merges leaves together with a separator. Say you want three characters × four styles × two cameras. Put them in the JSON, set the separator to , , and the node hands back 24 prompts. That feeds a queue loop or a batch sampler, and suddenly a whole test grid is one JSON edit away.
The inputs that matter
json_input- the hierarchical JSON of prompt parts. Leaves get combined; you control the structure.separator(default", ") - what goes between merged parts. Comma-space is right for most anime-style prompting.include_keys/full_path_keys- optionally prefix each leaf with its JSON key (the last key, or the full path). Useful when your keys are meaningful labels likecharacterand you want them in the output.generate_root_prompts- include standalone root-level string leaves that aren't part of any branch.dedupe(defaulttrue) - remove duplicate final prompts, because overlapping parts create duplicates fast.max_combinations(default 5000) - the safety cap. This is the one that saves you: a few branches with many options each explodes combinatorially, and this stops the node from generating a quarter-million prompts by accident. The max is 200000, but the warning sign is if you need to raise it.shuffleandlimit- randomize the order, and cap the number of prompts after processing. Handy for sampling a subset of a huge grid.
Outputs
string / string_list - the combined prompts (single / list). count - how many prompts were generated, so you know what you just committed to. json - the full set as JSON, if you want to inspect or post-process it. Feed string_list into whatever iterates over prompts for batch generation.
Installing it
One pack covers it:
cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/lf-nodes
restart ComfyUI, or install "LF Nodes" from ComfyUI Manager. Pure JSON logic - no models, no downloads.
Common issues
- Way too many prompts -
max_combinationsis your friend. Check your JSON depth; a small tree can still explode if each level multiplies. - Duplicates everywhere - leave
dedupeon unless you have a reason. Overlapping leaf values across branches are the usual culprit. - Keys leaking into prompts - you've enabled
include_keyswithout wanting it, or the JSON itself has label keys as leaves. Disable it, or restructure the JSON so only real prompt text is a leaf.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| json_input | JSON | Hierarchical JSON of prompt parts. | |
| separatoropt | STRING | , | Separator between merged parts. |
| include_keysopt | BOOLEAN | false | Include path keys before each leaf. |
| full_path_keysopt | BOOLEAN | false | If true and include_keys, use full path; else only last key. |
| generate_root_promptsopt | BOOLEAN | false | Include standalone root-level direct string leaves. |
| dedupeopt | BOOLEAN | true | Remove duplicate final prompts. |
| max_combinationsopt | INT | 50001–200000 | Safety cap. |
| shuffleopt | BOOLEAN | false | Randomize order (after generation, before limiting). |
| limitopt | INT | 0 | If > 0, limit number of prompts after processing. |
| ui_widgetopt | LF_CODE | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| string | STRING | Combined prompt string. |
| string_list | STRING | List of combined prompt strings. |
| count | INT | Number of prompts generated. |
| json | JSON | JSON representation of all prompts. |