Nodes/ComfyUI-Light-Tool/Light-Tool: Get values from JSON
ComfyUI Node

Light-Tool: Get values from JSON

Pull a value out of JSON by dotted path, arrays included

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Get values from JSON
    • value
    data{"key": "This is value"}
    keykey

    LLM nodes, API calls, metadata dumps - ComfyUI workflows keep tripping over JSON strings, and the annoying part is always the same: you have the data, you just need one field out of it. Light-Tool: KeyValue does exactly that. Give it a JSON string and a key path, get the value back, no jq install required.

    Two inputs: data, the JSON string (multiline, and it ships with {"key": "This is value"} as the example default so you can see the shape immediately), and key, the path you want. One output: value, typed as a wildcard (*), which means it can flow into string, number, or even downstream JSON nodes depending on what's at the end of the path.

    The key syntax is where the power is. The path supports dot notation and array indexing, mixed freely:

    • name → the name field
    • user.profile.age → nested lookup
    • items[0].title → first item's title
    • results[2].data.seed → deep paths with arrays anywhere in the chain

    Each segment first splits on dots, then handles [n] index lookups inside the segment, walking the JSON structure step by step. That single syntax covers most real API responses and most metadata blobs without needing a regex node or a Python-exec hack.

    The trap. Missing anything - malformed JSON, a path that doesn't resolve, an index out of range - returns an empty string '', silently. No error, no warning. If you wire that into a node that treats empty as "missing value," you're fine; if the downstream node happily uses the empty string as real data, you'll get a confusing result an hour later. When you're building a workflow around API responses that change shape, put this node's output through a check or expect to debug the empty-string path.

    Why it's worth having. Structured outputs from LLM nodes are the big one - a JSON-returning chat node hands you a string, and you need one number out of it to feed a KSampler seed or a float widget. Also handy for pulling fields out of image metadata you fetched from a URL (LoadMetadataFromURL in this pack outputs exactly the kind of JSON this node parses). It's a small node that removes a whole category of "I have a dict but it's actually a string" friction.

    Installing. Part of ComfyUI-Light-Tool:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ihmily/ComfyUI-Light-Tool.git
    pip install -r requirements.txt
    # restart ComfyUI
    

    Or ComfyUI Manager → search ComfyUI-Light-Tool → Install. No models. The node itself is pure Python stdlib - json and re - so it doesn't even touch the pack's heavier dependencies.

    Verdict: the pack's most underrated node. If you feed it clean JSON, it's a genuinely pleasant little utility. If you feed it hostile JSON, remember it fails to an empty string rather than a loud error - and plan accordingly.

    CategoryComfyUI-Light-Tool/DataProcessing

    Inputs (2)

    NameTypeDefaultDescription
    dataSTRING{"key": "This is value"}
    keySTRINGkey

    Outputs (1)

    NameTypeDescription
    value*