Nodes/OmniNodes/JSON Field Extractor πŸ”Ž
ComfyUI Node

JSON Field Extractor πŸ”Ž

Pull Anything Out of Nested JSON

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
JSON Field Extractor πŸ”Ž
  • json_input
  • value_string
  • value_raw
  • found
  • summary
β—„field_pathdata.0.nameβ–Ί
β—„fallbackβ–Ί

Some API response arrives as a wall of nested JSON, and you need exactly one value out of it: the job ID, the seed the cloud service used, the download URL. That's the whole job of JSON Field Extractor. You give it a JSON blob and a path, it hands back one value on a wire you can actually plug into something else. It doesn't call any API and needs no key - it's a parser, and it's the connective tissue between the Web API nodes in OmniNodes (HTTP Request, Endpoint Poller) and the rest of your graph.

How it works

The dot-path is the whole trick. data.items.0.title means: from the top level, take data, then items, then the first array element (the 0), then its title. Numeric segments index into arrays, which is how you reach the third result of a search response instead of the first. You can also feed it a raw JSON string - say, an HTTP Request's response_text - and it auto-detects and parses it. A dict from response_json works on the same socket, no mode switch.

The part that makes it workflow-safe: if the path doesn't resolve (missing key, out-of-range index, trying to descend into a number), it doesn't crash the queue. found goes False and value_string returns whatever you put in fallback. A typo'd path costs you a missing value, never a dead run.

Inputs and outputs that matter

Three inputs, and honestly only two are interesting:

  • json_input - a dict or a JSON string; either works on the same socket.
  • field_path - the dot-path, default data.0.name.
  • fallback - the string returned when the path fails.

Outputs: value_string (the extracted value as text, or the fallback), value_raw (the value with its original type preserved), found (a real boolean you can wire into a Conditional Gate), and summary (a text recap of what happened).

Where it fits

The classic wiring is HTTP Request β†’ JSON Field Extractor β†’ whatever needs the value. Pull the status field out for Endpoint Poller, grab the returned seed and feed it to a KSampler, or route on found so a failed lookup skips the save node instead of writing junk. It's the same fallback-first-null thinking that the plumbing layer of ComfyUI runs on everywhere - fail soft, keep the graph alive, let a gate decide what matters.

Install

Same story as every OmniNodes node. Either ComfyUI Manager (search "OmniNodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes

Then restart ComfyUI. One heads-up specific to this category: the pack's requirements.txt declares requests, and it is genuinely needed by its Web API siblings (HTTP Request, Endpoint Poller, Discord Notify) - ComfyUI doesn't bundle it. This node itself only uses the standard library's json, so it works even if you never run pip install -r requirements.txt. If you want the rest of the category, run it:

cd ComfyUI/custom_nodes/OmniNodes
pip install -r requirements.txt

Then restart again.

Troubleshooting

  • found is always False. Check the path against the actual response. A quick sanity move: wire summary to a text preview node and read what it says the input was. If it says the input wasn't valid JSON, the upstream node didn't hand you JSON.
  • Value comes back as the fallback. That's the path not resolving - the array index is off by one, or a key name has different casing than you typed.
  • You got a list instead of a value. The extractor returns one element. If you want several, either call it a few times or grab the array into value_raw and let a downstream node work on it.

It's a small node and it should be - it does one thing, does it without raising, and gets out of your way. For anyone gluing cloud jobs into a local ComfyUI graph, it's the piece that turns a raw JSON dump into a wireable number.

CategoryTensorVizion/Web API

Inputs (3)

NameTypeDefaultDescription
json_input*β€”
field_pathSTRINGdata.0.nameβ€”
fallbackSTRINGβ€”

Outputs (4)

NameTypeDescription
value_stringSTRINGβ€”
value_raw*β€”
foundBOOLEANβ€”
summarySTRINGβ€”