Nodes/ComfyUI-LogicUtils/Pyobjects/JSON -> PyObject
ComfyUI Node

Pyobjects/JSON -> PyObject

Turn a JSON string into a live Python object

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Pyobjects/JSON -> PyObject
    • *
    json_string{"key": "value"}

    This is the mirror image of JSON Dump, and the two exist as a pair: Dump turns a Python object into text, Parse turns text back into a Python object you can actually operate on inside the graph.

    What it does

    One required input, json_string (a STRING, defaulting to {"key": "value"} so you can see the expected shape without reading docs that don't really exist). Feed it valid JSON - an object, an array, a number, whatever - and it comes out the other side as a live Python value on the wildcard output. If your string was a JSON object, you get a dict. If it was a JSON array, you get a list, which is exactly the shape List Get, List Append, and the rest of LogicUtils's list nodes expect.

    The practical use case: you've got structured data arriving as a string - pasted into a text widget, pulled out of an API node's response, embedded in a workflow input - and you need to actually work with it rather than just display it. Parse turns that string into something the rest of the pack, or Python-object-aware logic downstream, can index into, iterate over, or compare against.

    It's marked as an output node too, so it'll run and hold its result even without anything wired past it - handy if you're just sanity-checking that a string parses at all before you build the rest of the chain.

    The inputs and outputs that matter

    • json_string (required STRING, default {"key": "value"}) - the text to parse. Has to be valid JSON: double-quoted keys and strings, no trailing commas, true/false/null in lowercase.
    • Output: a single wildcard * port carrying whatever the JSON deserializes to - dict, list, string, number, or boolean.

    Installing it

    Same as every other node in this pack: ComfyUI Manager, search ComfyUI-LogicUtils, install, restart - or cd ComfyUI/custom_nodes && git clone https://github.com/aria1th/ComfyUI-LogicUtils by hand, then restart. No model downloads, nothing heavy in the dependency graph; a Reddit thread recommending lightweight logic nodes specifically called this pack out for having none. There's an opt-in auto-install hook (COMFYUI_LOGICUTILS_AUTO_INSTALL=1) and a way to force it off (COMFYUI_LOGICUTILS_SKIP_INSTALL=1), but with nothing heavy to install in the first place, you're unlikely to ever need either.

    Where people get burned

    The obvious one: malformed JSON. Python's json.loads() is strict - single quotes instead of double quotes, a trailing comma, an unquoted key, and the node throws instead of quietly guessing what you meant. If you're typing JSON by hand into the widget rather than wiring it from somewhere else, run it through any online JSON validator first if the error message isn't telling you enough.

    Second: the output is wildcard-typed, which means ComfyUI won't stop you from wiring it into a port that expects something specific - it'll just fail at run time if the shapes don't line up. If your JSON string is an object ({"a": 1}) and you try to feed the result straight into a node expecting a LIST, that's not going to work; you parsed a dict, not a list. Check what your JSON actually deserializes to before assuming the downstream node will take it. And since this pack's own documentation is, in its author's words, still "being prepared," the info panel on this page and the node's source are genuinely your best references if something behaves unexpectedly.

    CategoryData

    Inputs (1)

    NameTypeDefaultDescription
    json_stringSTRING{"key": "value"}

    Outputs (1)

    NameTypeDescription
    **