ConvertToJsonStr
ConvertToJsonStr – ComfyUI Node
- obj
- json_str
What it is
ConvertToJsonStr does exactly what it says: hand it anything - a dict, a list, a number, whatever object is flowing down a wire - and it hands back a JSON-serialized string of it. That's the whole node. No parsing, no filtering, no schema. It's json.dumps() wearing a ComfyUI socket.
The reason this earns a spot in a pack literally named "easyapi" is that ComfyUI, run as an API backend rather than a UI you're staring at, communicates mostly in strings and JSON blobs over the websocket. If you're building a workflow meant to be called programmatically - where the caller expects a clean JSON payload back, not ComfyUI's internal Python objects - you need something at the boundary that turns "internal data structure" into "text you can actually return." That's this node's entire job. It's also handy inside the editor itself: wire any output into it and a ShowString node downstream, and you can inspect exactly what shape of data a node is emitting without guessing.
How it works
There's no real mechanism to explain beyond "serialize this to JSON." The one thing worth knowing is that it accepts type * - anything - which means ComfyUI won't stop you from plugging in something that genuinely can't be JSON-serialized (a raw tensor, an image object, a custom Python class with no __dict__ story). If you feed it something like that, expect an error rather than a string, because JSON serialization has real limits regardless of how permissive the input socket looks.
Inputs and outputs
One input: obj, type * (required) - literally anything on the graph. One output: json_str, type STRING - the serialized result.
That's it. The value of this node is entirely in where you put it, not in any configuration it exposes.
Installing it
It comes bundled in comfyui-easyapi-nodes. Through ComfyUI Manager, search "comfyui-easyapi-nodes" and install. 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 after. This particular node needs nothing beyond Python's standard library, but running the pip install step anyway is worth it so the rest of the pack's nodes (several of which do have real dependencies) aren't left half-broken. Upgrade later with a git pull in the same folder.
Common issues
"It threw an error instead of giving me a string." Whatever you fed it isn't JSON-serializable as-is - a raw IMAGE tensor is the classic case. Convert to something serializable first (this same pack's GetValueFromJsonObj or a plain Python-list-friendly output, or one of the pack's base64-image nodes if it's genuinely image data you're trying to ship as text).
"The output looks like Python's repr, not real JSON." It shouldn't - this is a straight JSON dump, not a str() call - but if you're piping the string through another node that reformats it (a text concatenation node, for instance) before you look at it, that's the more likely culprit than this node itself.
"I just want to eyeball what's on a wire while building a workflow." This is a legitimately good debugging habit even outside API work: drop a ConvertToJsonStr + a display/show node on any suspicious connection and you'll see the actual shape of the data instead of guessing from a node's tooltip.
The README's framing for the whole pack is worth keeping in mind here: these nodes exist because driving ComfyUI as an API is a different job than clicking through the UI, and JSON is the lingua franca of that job. Nodes like this one are the connective tissue that makes it possible without writing custom Python on the client side.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| obj | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| json_str | STRING | — |