Nodes/Quality of Life Nodes for ComfyUI/JSON Value Parser (Soze)
ComfyUI Node

JSON Value Parser (Soze)

Pull one key out, already cast to the type you need

By SozeInc·Created 2 years ago·Updated 5 days ago· 10
JSON Value Parser (Soze)
    • string_value
    • int_value
    • float_value
    • bool_value
    • any_value
    • formatted_json_text
    json_string
    key
    string_value_word_limit0
    default_value
    use_default_on_errorfalse

    You've got a JSON string somewhere in your graph - from an API response, a loaded config, a previous node's output - and you need one field out of it, cast to whatever type actually matters downstream. Doing that by hand means picking apart the string and casting the result yourself. This node does both steps and, rather than making you pick a return type up front, gives you the value in every common type at once so you just take the socket that fits.

    How it works

    Feed it json_string and the key you want. It looks the key up and returns it simultaneously as a string, an int, a float, and a bool, plus a generic "any" version - wire whichever output your next node actually expects. formatted_json_text gives you the whole object pretty-printed alongside, useful as a sanity check while you're figuring out what keys actually exist.

    Two things soften the sharp edges of a bare parser. string_value_word_limit caps how many words the string output carries - set it above 0 and a long field gets truncated before it lands in, say, a filename or a caption, instead of you adding a separate truncation step. And default_value combined with use_default_on_error means a missing key doesn't have to break your run: turn that flag on and a key that isn't present returns your fallback instead of an error string.

    Nothing in the schema suggests this handles nested or dotted keys (parent.child) - key reads as a flat, top-level lookup. If your JSON has nested objects, flatten what you need before this node, or confirm the exact key syntax it expects rather than assuming JSONPath-style access works.

    The inputs and outputs that matter

    • json_string / key (required) - the source and the field you want.
    • default_value + use_default_on_error (optional) - the fallback pair; turn the flag on for any key that isn't guaranteed to be present.
    • string_value_word_limit (optional, default 0 = no limit) - truncate the string output.

    Outputs: string_value, int_value, float_value, bool_value, any_value, formatted_json_text.

    How to install it

    ComfyUI Manager → search "ComfyUI_Soze" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/SozeInc/ComfyUI_Soze.git
    pip install -r ComfyUI_Soze/requirements.txt
    

    then restart. No external dependency beyond the base pack.

    Common issues & troubleshooting

    If your workflow errors on a field that's sometimes just missing from the source JSON (an optional API field, for instance), use_default_on_error is the fix - leave it off and a missing key is treated as a hard failure, on and it quietly falls back to default_value.

    If a numeric output comes back as 0 or a bool as false unexpectedly, check whether the key actually exists versus genuinely holding that value - with use_default_on_error off, that distinction matters, and it's worth glancing at formatted_json_text to confirm what's really in the object before assuming the node mis-parsed something.

    Pairs directly with JSON File Loader upstream (load the file, then pull specific keys here) and with the pack's ComfyDeploy nodes if you're extracting values out of an API response.

    CategorySoze Nodes

    Inputs (5)

    NameTypeDefaultDescription
    json_stringSTRING
    keySTRING
    string_value_word_limitoptINT00–10000Limit the number of words in the returned string value. 0 means no limit.
    default_valueoptSTRINGDefault value to return if key is not found.
    use_default_on_erroroptBOOLEANfalseIf true, return the default value when the key is not found instead of an error message.

    Outputs (6)

    NameTypeDescription
    string_valueSTRING
    int_valueINT
    float_valueFLOAT
    bool_valueBOOLEAN
    any_valueSTRING
    formatted_json_textSTRING