xbhh JSON预设选择器
The one-liner JSON preset picker for people tired of editing prompts in the node
- STRING
- STRING
You've got a JSON file full of saved prompts - maybe a stash of your best character descriptions, style blocks, or negative sets - and you keep editing one giant text widget by hand. The PresetSelector from the XBHH kit is the lazy fix: point it at a preset.json, pick a key from a dropdown, and it hands you the value as text. No API calls, no keys, no network. It's a file reader with a nicer face.
It ships in the same pack as the XBHH Multi Lora Loader and the rest of the xbhh kit, and it's squarely aimed at the ComfyUI habit of embedding whole workflows as PNG metadata and swapping values in the graph rather than in the file. If you batch-generate and swap prompt blocks a lot, this beats re-typing them.
How it works
The node scans a JSON file and builds its keys dropdown from the top-level keys of that file - at node load time. So the flow is:
- Drop a
preset.jsonintoComfyUI/user/xbhh/(its preferred location), or anywhere and give it an absolute path. - Add the node, and the
keysdropdown fills with the keys from that file. - Pick one, and the node returns the matching value.
File resolution follows a fixed order: absolute path if you give one, then ComfyUI/user/xbhh/<name>, then the ComfyUI working directory, then the plugin's own folder. That user/xbhh/ folder is where this whole pack keeps its persistent files - the txt selector and the LoRA trigger-word SQLite database live nearby, so it's worth knowing about.
The inputs that matter
- preset_file - the JSON path, defaulting to
preset.json. This is the one you'll actually set. - keys - the dropdown of JSON keys, auto-populated from the file when the node loads. Choose the block you want out.
The node has two STRING outputs, and they're both just text versions of the same pick: the first is the key: value pair, the second is a "current value" display string. Either wires straight into a CLIP Text Encode or whatever else wants a prompt string. If the key you picked doesn't exist in the file, both outputs tell you so with a ⚠️ message instead of crashing the graph - which is friendlier than a lot of custom nodes manage.
Installing it
This is a node inside the XBHH kit, not a standalone install:
cd ComfyUI/custom_nodes
git clone https://github.com/xbhh123456/Comfyui-xbhh-main.git
cd Comfyui-xbhh-main
pip install -r requirements.txt
Or use ComfyUI Manager and search for xbhh-lora (that's the Manager search term the author ships in the README). Then restart ComfyUI. Nothing model-related is downloaded - the only real Python dependency in the whole kit is openpyxl for the XLSX viewer, so install is fast.
Where people get burned
The dropdown is built when ComfyUI loads the node definitions. Add a new key to your JSON while ComfyUI is running and the dropdown won't see it until you restart the frontend - or at minimum reload the workflow. Keep that in mind and the node behaves. Also, if the file path is wrong, the dropdown comes up empty with a "(无可用键)" note, which reads like a bug until you check the file location. It's user/xbhh/preset.json relative to your ComfyUI install - not the plugin folder.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| preset_file | STRING | preset.json | JSON文件路径(优先从 ComfyUI user/xbhh/ 目录读取) |
| keys | COMBO | prompt | 可选键: (无可用键) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |
| STRING | STRING | — |