Nodes/WorkflowX Configurator/JsonX - Template Randomizer
ComfyUI Node

JsonX - Template Randomizer

Vary the fields you choose, keep the rest frozen

By haroonaslam·Created 4 months ago·Updated 7 days ago· 10
JsonX - Template Randomizer
    • prompt_json
    • run_log
    template_name
    randomize_rules
    randomize_rules_helpJsonX Randomize Rules (one line per field): path | mode | value Examples: scene.environment | preset | indoor photography studio, seamless backdrop subjects[0].dress.top.color | preset | topcolor_black; topcolor_white; topcolor_red subjects[0].custom_tag | custom | alpha; beta; gamma Notes: - mode is visual only; runtime recomputes mode from field metadata. - If value equals the template current value: - preset-backed fields randomize from preset options - custom-only fields remain unchanged - If value differs from template current value, semicolon-separated values are used as override candidates.
    seed0

    You've built a structured JSON prompt template - scene, subject, camera, lighting. Now you want to generate a batch of variations: same scene, same subject, but the dress color rolls through a few options and the lighting swaps between two presets. JsonX - Template Randomizer is the node for exactly that. It takes a saved template, applies rules that say which fields may vary and what they may vary over, and emits a randomized prompt_json - with a seed, so a given run is reproducible.

    It's the third JsonX node in WorkflowX, and the one that turns a good template from a one-time document into a source of variations. If the Visual Builder is how you compose, the Randomizer is how you explore.

    How it works

    The node loads templates and presets from local files the JsonX frontend saves into the pack's directory (presets.json and the templates/ folder). You pick a template_name, and the node deep-copies the template's tree so it never mutates your saved original.

    The randomize_rules field is a simple text format, one rule per line:

    path | mode | value
    scene.environment | preset | indoor photography studio, seamless backdrop
    subjects[0].dress.top.color | preset | topcolor_black; topcolor_white; topcolor_red
    subjects[0].custom_tag | custom | alpha; beta; gamma
    

    Path targets a field in the JSON tree (subjects[0].dress.top.color style), mode is informational (runtime recomputes it from field metadata), and value matters in two ways: if it equals the template's current value, the field randomizes from its preset options; if it differs, the semicolon-separated values become the override candidates. Preset-backed fields randomize from their preset library; custom-only fields stay unchanged unless overridden.

    Two things to know. First, seed - set it to 0 and the run is non-reproducible; set a positive seed and the same template+rules+seed always gives the same picks. That's the property you want when you find a good variation and need to get back to it. Second, the run_log output documents what changed, so a batch of images stays auditable - you can see which variant produced which result.

    Inputs and outputs

    • template_name (STRING) - a template saved via the JsonX UI.
    • randomize_rules (STRING) - one rule per line as above.
    • seed (INT) - 0 = random, positive = reproducible.
    • Outputs: prompt_json (STRING) - the compiled randomized prompt; run_log (STRING) - the audit trail.

    Install

    Part of WorkflowX-Configurator - Manager search WorkflowX Configurator, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/haroonaslam/WorkflowX-Configurator
    

    Restart and hard-refresh (the JsonX UI is a frontend extension). No extra Python dependencies.

    Common issues

    • "Template name is required" / "Selected template not found." - nothing saved under that name in the pack's templates/ folder. Create and save one from the Visual Builder first.
    • Fields aren't randomizing. The rule's value must differ from the template's current value to act as overrides, or match it to trigger preset-based randomization. If the field is custom-only and the value matches, nothing changes - that's the documented behavior, not a bug.
    • Can't reproduce a good run. Use a positive seed and keep template + rules identical.

    Where this sits in the ecosystem: prompt variation tooling is an old idea, but doing it on structured JSON with an audit log and seed control is a genuine step up from string-replacement tricks. If you're already driving an LLM-encoded model with JSON prompts, this is the node that makes template-based batch generation pleasant instead of painful.

    CategoryWorkflowX/Prompting/JsonX

    Inputs (4)

    NameTypeDefaultDescription
    template_nameoptSTRING
    randomize_rulesoptSTRING
    randomize_rules_helpoptSTRINGJsonX Randomize Rules (one line per field): path | mode | value Examples: scene.environment | preset | indoor photography studio, seamless backdrop subjects[0].dress.top.color | preset | topcolor_black; topcolor_white; topcolor_red subjects[0].custom_tag | custom | alpha; beta; gamma Notes: - mode is visual only; runtime recomputes mode from field metadata. - If value equals the template current value: - preset-backed fields randomize from preset options - custom-only fields remain unchanged - If value differs from template current value, semicolon-separated values are used as override candidates.
    seedoptINT00–2147483647

    Outputs (2)

    NameTypeDescription
    prompt_jsonSTRING
    run_logSTRING