GetJsonKeyValue
API-key rotation and config lookup from a plain JSON file
- key_value
GetJsonKeyValue reads a simple JSON file - a top-level dictionary of key: value pairs - and hands you one of its values as a string. The README's framing is API-key rotation, and that's a genuine use case: keep a pool of keys in a file, let this node pick one, and you never touch a widget mid-generation. But it's really a generic "look up a config value from a file" node, and it works for any string you want to store outside the graph.
How it works
Point it at a .json file with json_path (default ./input/JSON_KeyValueStore.json - the repo ships a matching JSON_KeyValueStore.json example with {"key_id_1": "put_key_here", ...} format). At execution the node loads the file and picks a value by key_id_method:
custom- return the value whose key name you typed intokey_id.random_rotate-random.choiceover all values, so each run grabs a random key.increment_rotate- pickvalues[rotation_interval % len], so changingrotation_intervalsteps through the list.
The output is a single key_value string. Errors are loud and specific in the source: file not found, JSON that isn't a dict, an empty dict, or a custom key that doesn't exist all raise a descriptive error naming the problem.
The two inputs that actually matter
key_id_method- the picker:custom,random_rotate, orincrement_rotate.key_id- only used incustommode; the tooltip says it plainly: "Put name of key in the .json here if using custom in key_id_method."
rotation_interval is the one that trips people. The tooltip calls it "how many steps to jump when doing rotate," but the code treats it as a direct index into the list each run - there's no accumulating counter. Set it to 2 and you always get the third entry, not "advance by two from last time." If you want true rotation across runs, random_rotate is the mode that actually rotates.
Where it earns its keep
- Key rotation: store ten API keys, run
random_rotate, and you spread your usage instead of hammering one key - handy for rate-limited services. - Central config: keep strings (URLs, prompts, model names) in one file instead of scattered widgets, and change them without editing the graph.
The obvious caveat: it's plaintext on disk, so don't put secrets you can't afford to leak here - the README's own example is literally "put_key_here".
Install
ComfyUI Manager → search ComfyUI_SamplingUtils, or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI_SamplingUtils
then restart ComfyUI. Real dependencies from requirements.txt: kornia, scipy, pilgram, opencv-python, unifiedefficientloader>=0.5.0. The pack's README declares it DEPRECATED in favor of ComfyUI-UtilsCollection, but this node is self-contained and stable - it'll keep working either way.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| json_path | STRING | ./input/JSON_KeyValueStore.json | Path to a .json file with simple top level structure with key and value. See example in custom node folder. |
| key_id_method | COMBO | 3 options: custom, random_rotate, increment_rotate | |
| rotation_interval | INT | 0 | how many steps to jump when doing rotate. |
| key_id | STRING | placeholder | Put name of key in the .json here if using custom in key_id_method. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| key_value | STRING | — |