Nodes/comfyui-snek-nodes/🐍 Random Prompt From JSON
ComfyUI Node

🐍 Random Prompt From JSON

A wildcard node that shipped its own prompt files

By snecccΒ·Created 2 years agoΒ·Updated 12 months agoΒ· 1
🐍 Random Prompt From JSON
    • randomized_prompt
    β—„json_fileβ–Ύβ–Ί
    β—„modeallβ–Ί
    β—„seed0β–Ί

    Most random-prompt nodes make you bring your own word lists. This one ships with seven themed JSON files already loaded, so it's useful the minute it's installed - and if you want your own prompts, the file format is simple enough to copy from the bundled examples.

    What it is. 🐍 Random Prompt From JSON is a wildcard-style prompt randomizer. Pick a JSON file and a "mode," give it a seed, and it returns a randomized prompt string. Templates in the file contain placeholders like {adjective}, and each placeholder is filled with a random pick from that file's category list. It's the same old wildcard idea that A1111 users had for years - the KB notes most people arriving after 2024 never learned that syntax, so think of this as that concept, dressed in JSON and running natively in ComfyUI.

    The bundled files are actually fun: app_icons.json, character_actions.json, double_exposure_creative.json, nsp_inspired.json (the neon night-photography aesthetic), object_locations.json, random_prompt.json, and silver_chrome_objects.json. Each one carries a set of modes - double_exposure_creative, for instance, has ~40 modes you can pick, or just leave it on all and let the node draw from every template in the file.

    How it works. On startup the node scans nodes/random_prompt/*.json, validates each file, and caches its modes and categories. When you run it, random.seed(seed) is set, a template is chosen with random.choice, and every {placeholder} is replaced with a random value from the matching category. There's also a little JavaScript sidecar: when you change the json_file dropdown, it calls the node's own /snek/get_modes/{filename} API endpoint and repopulates the mode dropdown with only the modes that file actually supports. That's a genuinely nice touch for a small pack.

    Inputs and outputs. Three inputs, one output:

    • json_file (enum) - one of the seven bundled files (or yours, once you drop them in).
    • mode (enum) - a specific mode for that file, or all to sample every template.
    • seed (INT) - reproducibility. Leave it fixed and you get the same prompt every run; randomize it to wander.
    • randomized_prompt (STRING) - wire this into a CLIP Text Encode, and from there into your positive conditioning.

    Installing it. Same pack as everything else here:

    cd ComfyUI/custom_nodes
    git clone https://github.com/sneccc/comfyui-snek-nodes
    

    or search "comfyui-snek-nodes" in ComfyUI Manager and restart. No model downloads - it's pure text generation.

    Where people get burned.

    • Seed 0 is a trap. With a fixed seed you'll get the exact same prompt on every queue. The node is often used with a randomize seed widget, but nothing in the node nudges you to do that.
    • Your own JSON gets silently skipped if it's the wrong shape. The node requires a categories object plus either a modes dict or a legacy templates list. A file with just a list of strings won't load, and the only warning is a console line during startup. Copy a bundled file as your template and edit it.
    • Restart after adding files. The JSON cache is built once at startup. New files need a ComfyUI restart; new modes in an existing file do too.
    • Modes that don't exist fall back to all. The dropdown is per-file, but if a mode from one file is selected against another, the node logs a warning and samples everything. Not a bug, just surprising the first time.
    • Unfilled placeholders stay in your prompt. If a template references {something} with no matching category, the literal {something} passes through into your text encode. Usually harmless, occasionally ugly.

    Bottom line. The most genuinely useful node in the pack: it works out of the box, the bundled files give real variety, and the seed control makes it reproducible. If you're after one node from comfyui-snek-nodes, this is it.

    Category🐍 Snek Nodes

    Inputs (3)

    NameTypeDefaultDescription
    json_fileCOMBO7 options: app_icons.json, character_actions.json, double_exposure_creative.json, nsp_inspired.json, object_locations.json, random_prompt.json, +1
    modeCOMBOall40 options: all, 3D_REALISTIC, ADJECTIVE_FOCUS, ARTISTIC_METALLIC, ARTIST_FOCUS, ATMOSPHERIC_SCENE, +34
    seedINT00–18446744073709550000β€”

    Outputs (1)

    NameTypeDescription
    randomized_promptSTRINGβ€”