Nodes/ComfyUI_NYJY/JsonLoads(NYJY)
ComfyUI Node

JsonLoads(NYJY)

Turn a JSON string into something ComfyUI can actually use

By aidenli·Created 2 years ago·Updated 4 months ago· 146
JsonLoads(NYJY)
    • json_data
    text

    ComfyUI runs on JSON under the hood - every workflow save is one - but as soon as you move past the built-in nodes, JSON also becomes the thing you receive as a string: an API response, a file you loaded, a chat model's answer. That string is useless until something parses it. JsonLoads is that something: feed it a JSON string and it hands you a real JSON object you can route into other nodes.

    It's part of ComfyUI_NYJY, a Chinese utility pack from aidenli that bundles local captioning tools, translation nodes, a pile of cloud-API wrappers, and a handful of logic helpers like this one. The logic nodes are the quiet workhorses - nothing flashy, but they're the glue that lets you automate a workflow instead of hand-copying text.

    How it works. There's exactly one input and one output, which is the whole appeal. text is a multiline string field - paste a JSON blob in, or wire it up from a node like ReadFileToString (same pack) or VolcengineChat when that model returns JSON. The node runs Python's json.loads() on it and pushes the result out as json_data, typed as JSON. From there you can plug into JsonGetValueByKeys (also in the pack) to walk a path like data.items.0.name, or into JsonDumps to stringify it again after you've transformed something.

    The one behavior worth knowing: invalid JSON doesn't crash the workflow. The node catches the parse error, returns an empty {} dict, and prints "Invalid JSON format" in its output text. So a failed parse silently becomes an empty object downstream - which means if everything after this node suddenly goes blank, suspect the input string, not your wiring. Trailing junk, a BOM, or unescaped quotes are the usual culprits, and pasting JSON straight from an LLM often carries all three.

    Install. This pack isn't a single-purpose install; the whole pack comes together:

    cd ComfyUI/custom_nodes
    git clone https://github.com/aidenli/ComfyUI_NYJY
    

    then restart ComfyUI and install requirements (ComfyUI Manager's "Install via Git URL" with https://github.com/aidenli/ComfyUI_NYJY works too). For just this node the dependencies are trivial - json is stdlib - but the pack's requirements.txt pulls in heavier stuff (transformers, bitsandbytes, …) for its captioning nodes, so the install is chunkier than the node itself. On Windows portable, double-click install.bat or run python_embeded\python.exe -m pip install -r requirements.txt.

    When to reach for it. Whenever a workflow hands you a text blob that is secretly structured data. The moment you want to read one field out of an API response instead of eyeballing the whole string, this is the node you reach for - and it's the cheapest way to make any chat or file node output programmable.

    CategoryNYJY/logic

    Inputs (1)

    NameTypeDefaultDescription
    textSTRING

    Outputs (1)

    NameTypeDescription
    json_dataJSON