ComfyUI Node

Get JSON Value

A JSON file as your config panel

By silveroxides·Created 2 months ago·Updated about 7 hours ago· 24
Get JSON Value
    • value
    json_path./input/values.json
    selection_modekey
    key
    index0
    seed0

    Somewhere between "typing the same prompt into six widgets" and "building a full API server" sits the workflow that wants its settings in one place. That's what UC_GetJsonValue is for: it reads a JSON file full of named values, picks one, and hands it to the graph with its type intact - a number stays a number, a string stays a string, a list stays a list. Change the file, re-run, done. No node surgery.

    It's a value-node problem, the same family as the "Convert widget to input" mechanic: one authoritative source, many consumers. Instead of a primitive widget it's a file, which means you can keep an entire batch's settings in one values.json and have a whole pipeline of nodes pull from it. Pair it with the pack's parameter nodes and you've got a workflow whose "panel" is a text file you can edit without touching the graph.

    How it works

    You point it at a file and pick a selection mode. The file must contain a top-level JSON object of named values - flat keys, each holding any JSON value. Then:

    • key mode returns the value at a named key.
    • random mode returns a deterministic random pick seeded by the seed input - same seed, same value, every run. This is the party trick: reproducible randomness without touching the graph.
    • index mode returns the value at a zero-based insertion-order index.

    Errors are loud and specific: missing file, undecodable JSON, a top-level list instead of an object, a key that isn't there, an index past the end - each raises a clear message rather than failing silently mid-pipeline.

    The inputs that matter

    • json_path - defaults to ./input/values.json, which is the natural place for it since that's ComfyUI's input folder. Relative paths resolve from the ComfyUI working directory.
    • selection_mode - key, random, or index.
    • key / index / seed - only the one matching your mode matters; the others are ignored.

    The single output is value, typed as * because it can be anything. It feeds whatever the JSON contained.

    Installing it

    ComfyUI Manager → search "ComfyUI-UtilsCollection", or clone it in:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
    

    Restart. Dependencies are opencv-python and typing-extensions - nothing heavy, no models. As with everything in this pack, it uses the newer ComfyExtension API, so keep ComfyUI current.

    Where it trips people up: the file has to be written before the node runs - there's no editor built in, so have a text editor handy. And the * output type means ComfyUI won't type-check your wiring for you; if you pull a string out of a spot you intended as an int, the mismatch surfaces downstream, not at this node.

    Categoryutils/primitive

    Inputs (5)

    NameTypeDefaultDescription
    json_pathSTRING./input/values.jsonPath to a JSON file containing a top-level object of named values.
    selection_modeCOMBOkeySelect a value by its key, a deterministic random choice, or its insertion-order index.
    keySTRINGTop-level JSON key to use when selection mode is key.
    indexINT00–9223372036854776000Zero-based insertion-order index to use when selection mode is index.
    seedINT00–18446744073709550000Seed used for deterministic random selection.

    Outputs (1)

    NameTypeDescription
    value*The selected JSON value in its original JSON type.