ComfyUI Node

JSON Query

Pull values out of JSON by key inside ComfyUI

By aidec·Created 2 years ago·Updated 9 months ago· 19
JSON Query
    • output_1
    • output_2
    • output_3
    • output_4
    • output_5
    • status
    input_modetext
    json_text{"a": {"name": "myname", "prompts": "mycustom prompt"}}
    json_file
    key_1
    field_1
    key_2
    field_2
    key_3
    field_3
    key_4
    field_4
    key_5
    field_5

    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 - text to paste JSON into the node, or file to read a .json from 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 (status is your clue that something didn't take).
    • Key/field has to match the structure. The node expects the key-then-field shape 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 .json has 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.

    CategoryTextBatch

    Inputs (13)

    NameTypeDefaultDescription
    input_modeCOMBOtext2 options: text, file
    json_textSTRING{"a": {"name": "myname", "prompts": "mycustom prompt"}}
    json_fileSTRING
    key_1optSTRING
    field_1optSTRING
    key_2optSTRING
    field_2optSTRING
    key_3optSTRING
    field_3optSTRING
    key_4optSTRING
    field_4optSTRING
    key_5optSTRING
    field_5optSTRING

    Outputs (6)

    NameTypeDescription
    output_1STRING
    output_2STRING
    output_3STRING
    output_4STRING
    output_5STRING
    statusSTRING