JSON Query
Pull values out of JSON by key inside ComfyUI
- output_1
- output_2
- output_3
- output_4
- output_5
- status
JSON Query is a little JSON reader that lives inside your graph. Feed it JSON - pasted in, or from a file - and it pulls out values by key, up to five at a time. If you keep per-image settings or prompt metadata in a JSON sidecar, this is how you get those fields into your workflow as plain strings without leaving ComfyUI.
It slots naturally into batch work. Say each image in your folder has a matching JSON blob with its prompt, its style tag, its seed. JSON Query lets you read those out and route them into the right nodes, so a batch can be data-driven rather than every item getting identical settings. It's one of aidec's experimental extras (the README documents the queue and loader nodes and files the rest as test pieces), but it does a genuinely common chore that ComfyUI otherwise makes annoying.
How it works
You give it a JSON document and up to five key/field pairs. For each pair it walks into the JSON and pulls the value, returning it on the matching output. The default sample - {"a": {"name": "myname", "prompts": "mycustom prompt"}} - shows the shape it expects: a key selects an object, a field selects the value inside it. Five lanes means you can extract several fields from one document in a single node.
The inputs that matter
- input_mode -
textto paste JSON into the node, orfileto read a.jsonfrom disk. - json_text - the JSON itself, in text mode. Comes pre-filled with a sample so you can see the expected structure.
- json_file - the path, in file mode.
- key_1 … key_5 / field_1 … field_5 (all optional) - the lookups. Each key/field pair drives one output. Fill only as many as you need.
Outputs: output_1 through output_5 (the extracted values as strings, one per key/field pair) plus status. Wire each output wherever that value belongs - a prompt into CLIP, a tag into a filename, and so on.
Installing it
cd ComfyUI/custom_nodes && git clone https://github.com/aidec/Comfyui_TextBatch_aidec, then restart ComfyUI (or ComfyUI Manager → Install via Git URL). No models, no heavy dependencies. Category: TextBatch.
Where people get burned
- Malformed JSON just fails. A stray trailing comma, a single quote where a double belongs, an unclosed brace - invalid JSON won't parse, and you'll get empty outputs. Validate the document first if it's hand-written (
statusis your clue that something didn't take). - Key/field has to match the structure. The node expects the
key-then-fieldshape shown in the sample. Deeply nested JSON, or arrays where it wants objects, may not map cleanly onto the two-level key/field model. If your data is more complex, reshape it or expect only the top levels to come out. - File paths are server-side. In file mode on a hosted ComfyUI, the
.jsonhas to live on the server, not your laptop. - Everything comes out as a string. Numbers and booleans arrive as text; convert downstream if a node needs a real int or float.
- Experimental tier. Thin docs and error handling - prototype with a small blob and watch
status.
For data-driven batches where each item carries its own settings, this is a surprisingly handy little node. For a flat prompt list, you don't need it.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| input_mode | COMBO | text | 2 options: text, file |
| json_text | STRING | {"a": {"name": "myname", "prompts": "mycustom prompt"}} | — |
| json_file | STRING | — | |
| key_1opt | STRING | — | |
| field_1opt | STRING | — | |
| key_2opt | STRING | — | |
| field_2opt | STRING | — | |
| key_3opt | STRING | — | |
| field_3opt | STRING | — | |
| key_4opt | STRING | — | |
| field_4opt | STRING | — | |
| key_5opt | STRING | — | |
| field_5opt | STRING | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| output_1 | STRING | — |
| output_2 | STRING | — |
| output_3 | STRING | — |
| output_4 | STRING | — |
| output_5 | STRING | — |
| status | STRING | — |