Nodes/Fal-Gateway/JSON Extract (Multiple)
ComfyUI Node

JSON Extract (Multiple)

Fan one LLM JSON object into N named STRING sockets

By modbender·Created 5 months ago·Updated 3 months ago· 1
JSON Extract (Multiple)
    • value_1
    • value_2
    • value_3
    • value_4
    • value_5
    • value_6
    • value_7
    • value_8
    • value_9
    • value_10
    json_string
    key_count1
    default
    key_1
    key_2
    key_3
    key_4
    key_5
    key_6
    key_7
    key_8
    key_9
    key_10

    Here's the workflow that makes people keep this pack installed: you set the schema widget on Fal Text-to-Text to flux_ref_prompt, motion_prompt, title, description, tags, run one Claude call, and get back a JSON object with all five fields. JSON Extract (Multiple) is the fan-out node that turns that object into five individual STRING outputs - each socket renamed after the key you typed, so you wire title straight into your filename node and never look at raw JSON.

    It's the same idea as the single-key extractor, but with the pack's signature counter UX: instead of dropping one node per field, you dial up how many fields you want and type a key into each row.

    Inputs and outputs

    • json_string - the JSON text, wired in (it's forceInput). Works with any upstream JSON STRING, not just this pack's LLM nodes.
    • key_count - an INT with +/- arrows, 1 to 10. Bump it to add rows, drop it to remove them.
    • default - one shared fallback for any key that's missing or any input that doesn't parse.
    • key_1 .. key_10 - one text row per active count. Type title into key_1 and the first output socket renames itself to title.

    Outputs: value_1 .. value_10, one STRING per row. The visible outputs track key_count, so a three-key node shows three sockets, not ten.

    How it works

    The frontend extension watches key_count and shows or hides rows and output sockets - the same trick the pack's Reference-to-Video and Reference-to-Image nodes use for image inputs. The backend always returns the full set of outputs padded with the default value, and the extension trims the visible ones. Missing key, unparseable JSON, or a key you didn't type → default. Nested objects come back serialized as JSON, primitives stringified. It never hard-crashes the graph, which is more than you can say for a lot of JSON plumbing.

    When you'd reach for it

    Any time an LLM returns a structured object and you want its fields as named sockets without copy-pasting extractor nodes. One Claude call → five outputs feeding a video prompt, a title, and a tag list is the canonical move. The single-key variant still wins when keys come from different upstream sources or you want a per-field default - this node's default is shared across all rows.

    Install

    Ships with ComfyUI-Fal-Gateway:

    cd ComfyUI/custom_nodes
    git clone https://github.com/modbender/ComfyUI-Fal-Gateway
    pip install -r requirements.txt
    

    Pure local string parsing - no API key needed here, though the LLM nodes upstream of it want one. Restart ComfyUI and it's under Fal-Gateway.

    Gotchas

    • Set the default. Models don't always honor response_format - a smaller model can return prose instead of JSON, and then every output comes back as your default. Empty default → empty sockets → confusing graph.
    • Hand-editing key_count past the declared range gets clamped back to 1–10, and blank rows return the default. Not something you'll hit from the UI, but it means the node won't explode on a stale workflow.

    If you've ever built a "parse the LLM output with three extractor nodes and a regex" monster, this is the tidy replacement: one node, typed sockets, done.

    CategoryFal-Gateway

    Inputs (13)

    NameTypeDefaultDescription
    json_stringSTRING
    key_countINT11–10
    defaultSTRING
    key_1STRING
    key_2optSTRING
    key_3optSTRING
    key_4optSTRING
    key_5optSTRING
    key_6optSTRING
    key_7optSTRING
    key_8optSTRING
    key_9optSTRING
    key_10optSTRING

    Outputs (10)

    NameTypeDescription
    value_1STRING
    value_2STRING
    value_3STRING
    value_4STRING
    value_5STRING
    value_6STRING
    value_7STRING
    value_8STRING
    value_9STRING
    value_10STRING