Check JSON Key [LP]
Check JSON Key [LP] — ComfyUI Node Guide
- exists
- value
The safe way to poke at JSON you're not 100% sure the shape of. Instead of assuming a key exists and letting a downstream node choke when it doesn't, this checks first and hands you a clean boolean plus the value if it's there.
What it's for
If you're building a workflow around JSON that isn't guaranteed to be consistent - an API response where a field is sometimes present and sometimes not, a config blob assembled conditionally earlier in the graph - reaching straight for the value with something like Get JSON Value risks the whole run erroring out on a missing key. Check JSON Key is the guard clause: it tells you whether the key is there at all, so you can branch your workflow (via a Switch or conditional node elsewhere) instead of crashing.
This is part of the same small JSON toolkit this pack shipped together - Get JSON Value, Get JSON Length, Stringify JSON, Merge JSON Node - added as a batch per the pack's changelog (JSON nodes landed in v1.3.4), with some of the group's lineage credited in the README to Comfyui-Simple-Json-Node by Q-Bug4.
Inputs and outputs
json_string(STRING, multiline) - note this takes a plain text field of JSON, not theJSONsocket type. That's the opposite ofGet JSON Valuein this same pack, which wants the parsedJSONtype - so if you're routing between these two nodes, expect to need a conversion step in between, not a direct wire.key(STRING, default empty) - the key you're checking for.
Outputs:
exists(BOOLEAN) - whether the key is present.value(STRING) - the value if it exists (behavior when it doesn't isn't specified beyond the boolean telling you not to trust it - treatvalueas only meaningful whenexistsis true).
Installing it
ComfyUI Manager: search "ComfyUI-LevelPixel," listed under "Level Pixel," install and restart. Manual route: cd ComfyUI/custom_nodes && git clone https://github.com/LevelPixel/ComfyUI-LevelPixel.git, restart ComfyUI. No models, no heavy dependencies - this is string parsing, nothing GPU-side involved.
Common issues
The biggest gotcha is the type mismatch mentioned above: this node's json_string input is a raw multiline STRING, not the pack's JSON object type used elsewhere in the same JSON toolkit. If you've got a JSON object already parsed by an upstream node and try to wire it straight in, the connection won't be valid - you'll need whatever's producing that object to also give you (or you to build) a string representation instead, which is exactly what Stringify JSON in this same pack is for.
Malformed JSON in the text box is the other obvious trap - a trailing comma, unescaped quotes, or a stray bracket will break parsing before the key check even happens. If the node isn't behaving as expected, paste the string into any JSON validator first to rule out a syntax error before assuming the node's logic is wrong.
Since value only makes sense when exists is true, don't wire value downstream without also checking exists somewhere in your graph - otherwise you risk silently propagating an empty or stale string when the key was never there to begin with.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| json_string | STRING | — | |
| key | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| exists | BOOLEAN | — |
| value | STRING | — |