Nodes/comfyui-easyapi-nodes/LoadJsonStrToList
ComfyUI Node

LoadJsonStrToList

Turn one JSON string input into a workable list

By lldacing·Created 3 years ago·Updated 8 months ago· 96
LoadJsonStrToList
    • LIST
    json_str

    An API request is, at the end of the day, a pile of JSON - and a lot of it doesn't map cleanly onto ComfyUI's typed sockets. LoadJsonStrToList is the bridge for the common case: your caller sends one JSON array as a string - a list of prompts, a batch of per-item settings, a set of bounding boxes - and you need it as an actual LIST inside the graph, not one opaque blob of text sitting on a STRING wire.

    How it works

    It's a straightforward parse: take the json_str field, run it through a JSON parser, hand back a native LIST. There's no schema validation or transformation beyond that - the entire contribution is giving the rest of the EasyApi pack something typed to iterate over instead of a string you'd otherwise have to parse yourself with a custom node.

    The inputs and outputs that matter

    • json_str (STRING, multiline, default empty) - the one field. Multiline so you can paste a formatted array straight in while testing.
    • The output is typed LIST - feed it into this pack's IndexOfList or SliceList to pull specific entries out, or into ListUnWrapper to run the rest of the graph once per item.

    How to install it

    Via ComfyUI Manager: search comfyui-easyapi-nodes, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
    cd comfyui-easyapi-nodes
    pip install -r requirements.txt
    

    Restart ComfyUI to pick it up; git pull in that folder later to upgrade. No models, nothing heavy.

    Common issues & troubleshooting

    It has to be genuinely valid JSON - double-quoted strings, no trailing commas, brackets balanced. The single most common way this breaks is someone pasting a Python-style list literal (['a', 'b'], single quotes) instead of an actual JSON array (["a", "b"]). That's a parse failure on your input, not a bug in the node.

    If you're building the JSON by hand while testing, run it through any JSON validator before pasting it into ComfyUI rather than debugging inside the graph - the node's error message won't point you at which character broke the parse, and a validator will.

    Also worth knowing: this node parses a JSON array into a list. If your string is a single JSON object instead ({"a": 1}), you'll get a one-item structure back rather than the flat list you might expect - check what your caller is actually sending before assuming the node mishandled it.

    That distinction matters more once you start chaining nodes: a LIST of plain values (strings, numbers) behaves differently downstream than a LIST of JSON objects. If each element is itself an object, you'll usually want this pack's GetValueFromJsonObj after this node to pull a specific field back out of each item, rather than trying to consume the raw object directly in a node that expects a simple string or number.

    CategoryEasyApi/Utils

    Inputs (1)

    NameTypeDefaultDescription
    json_strSTRING

    Outputs (1)

    NameTypeDescription
    LISTLIST