ComfyUI Node

KV Get Value

The KV node you'll actually spend time with

By millerlight·Created about a year ago·Updated about a year ago· 0
KV Get Value
  • store
  • value
  • key
key
default
as_typestring
keys_hint(dropdown enabled)
default_key
randomfalse

KV Get Value is the heart of the KVTools pack. Feed it a KV store from KV Load Inline or KV Load from Registry, tell it which key you want, and it hands you back the value - plus the key it actually resolved. It's an output node, so it can also sit at the end of the graph and show you what it read.

This is where the key/value idea stops being cute and starts being useful. You keep your prompts, character tags, or config values in one store, then sprinkle KV Get nodes around the graph to pull specific ones out - one for the positive prompt, one for the negative, one for a filename. Swap the store and every KV Get in the workflow follows.

How it works

The backend is a plain dict lookup: store.get(key, default). A few behaviors matter:

  • as_type casts the value to the type you ask for - string | int | float | bool. Note the value always comes out as a STRING; the cast just changes how it's rendered. If a cast fails (a non-numeric string as int), you get "0" rather than an error.
  • random only picks a random key when no valid key was provided. The source is explicit about this: it keeps the UI dropdown in sync with what the backend actually outputs. So if you've selected a key, random won't override it.
  • default_key kicks in only when key is empty - it's a UI-backed field (the "Set default" button writes it) rather than something you'd normally type.

The live dropdown and value preview are the real UX story. As soon as a store is connected, the key dropdown and preview populate without you hitting Queue. Switch the registry file and it updates automatically. That instant feedback is what makes the pack feel good to use.

The inputs that matter

  • store (KV) - the store to read from.
  • key (string) - gets a dropdown populated from the store's keys. This is what you'll actually touch.
  • default (multiline string) - returned when the key isn't found. Empty by default, so a missing key silently yields "".
  • as_type (enum: string/int/float/bool) - how to cast the value.

The optionals - random (boolean), plus the hidden keys_hint and default_key fields - are mostly driven by the right-click UI (Refresh keys, Random key, Set default, Load default).

Outputs: value (STRING) and key (STRING). Wire value into a CLIP Text Encode for prompts, or into any string input; key is handy when you want to know which key actually resolved.

Gotchas

  • The value is always a string. If your store value is a nested dict or list, it comes back as stringified JSON - fine for display, surprising for math.
  • If the dropdown is empty, your JSON isn't flat key/value, or the registry is stale - hit Refresh keys or restart ComfyUI to rebuild it.
  • Remember the store has to come from a KV node in the same pack; this won't read arbitrary JSON for you.

Install is the standard pack route (Manager → Install via URL → https://github.com/millerlight/ComfyUI-KVTools, or git clone into custom_nodes), with no extra dependencies - the pack's requirements.txt is empty.

CategoryKVTools

Inputs (7)

NameTypeDefaultDescription
storeKV
keySTRING
defaultSTRING
as_typeCOMBOstring4 options: string, int, float, bool
keys_hintoptSTRING(dropdown enabled)
default_keyoptSTRING
randomoptBOOLEANfalse

Outputs (2)

NameTypeDescription
valueSTRING
keySTRING