Nodes/lf-nodes/JSON Prompt Combinator
ComfyUI Node

JSON Prompt Combinator

Generate every prompt combination from one JSON blob

By lucafoscili·Created 2 years ago·Updated 6 days ago· 35
JSON Prompt Combinator
  • json_input
  • ui_widget
  • string
  • string_list
  • count
  • json
separator,
include_keysfalse
full_path_keysfalse
generate_root_promptsfalse
dedupetrue
max_combinations5000
shufflefalse
limit0

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 like character and you want them in the output.
  • generate_root_prompts - include standalone root-level string leaves that aren't part of any branch.
  • dedupe (default true) - 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.
  • shuffle and limit - 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_combinations is your friend. Check your JSON depth; a small tree can still explode if each level multiplies.
  • Duplicates everywhere - leave dedupe on unless you have a reason. Overlapping leaf values across branches are the usual culprit.
  • Keys leaking into prompts - you've enabled include_keys without 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.
Category✨ LF Nodes/JSON

Inputs (10)

NameTypeDefaultDescription
json_inputJSONHierarchical JSON of prompt parts.
separatoroptSTRING, Separator between merged parts.
include_keysoptBOOLEANfalseInclude path keys before each leaf.
full_path_keysoptBOOLEANfalseIf true and include_keys, use full path; else only last key.
generate_root_promptsoptBOOLEANfalseInclude standalone root-level direct string leaves.
dedupeoptBOOLEANtrueRemove duplicate final prompts.
max_combinationsoptINT50001–200000Safety cap.
shuffleoptBOOLEANfalseRandomize order (after generation, before limiting).
limitoptINT0If > 0, limit number of prompts after processing.
ui_widgetoptLF_CODE

Outputs (4)

NameTypeDescription
stringSTRINGCombined prompt string.
string_listSTRINGList of combined prompt strings.
countINTNumber of prompts generated.
jsonJSONJSON representation of all prompts.