Ⓜ️ JSON Builder
Mithril JSON Builder turns wires into key/value pairs
- json_string
Say you need a JSON document as a plain string - a config payload for an API, a structured prompt for an LLM node, a blob to hand to a webhook. The Mithril JSON Builder is the node for that, and its trick is that you build the JSON by wiring, not by typing JSON.
The node looks bare when you add it: one max_depth widget and a single ghost input labeled (new parameter). The magic is in that ghost. Drag a wire from any node's output into it, and the pack's frontend pops a prompt asking what to call the parameter. Give it a name, and the ghost input becomes a real named input holding your value - and a fresh ghost appears so you can keep adding more. Right-click any added input and you get "Rename Parameter" and "Remove Parameter." A "Remove Unconnected" button on the node strips any inputs with no wire attached.
When you run it, every connected input becomes a key/value pair in the output json_string - a single STRING you can feed to anything that wants text.
The mechanics, honestly
The Python side is dead simple: it collects whatever inputs are connected as keyword arguments and serializes them with the same recursive serializer the pack's Debug Viewer uses, honoring max_depth (default 3, 0–10) for nested structures. All the cleverness - the ghost input, the rename/remove menu, the parameter-name prompt - lives in the frontend JavaScript. That's the part to understand before you rely on it: the node's real interface is UI behavior, so it needs the frontend extension loaded, which means the normal install path, not some headless hack.
Two source-grounded quirks to expect:
- Parameter names get sanitized. Only letters, digits and underscores survive, and a leading digit gets an underscore slapped on.
my-valuebecomesmyvalue. Connect it, see the sanitized name, rename if it surprises you. - Duplicate names are rejected with a popup, and the offending link is removed. The ghost, meanwhile, deletes a parameter if you disconnect its wire - so unplugging is your delete.
One thing the info_schema won't tell you: all the dynamic inputs are created client-side, so the schema just shows max_depth. Don't be confused when the node grows inputs the schema never listed.
When it's worth it
Honestly, if you're hand-authoring one JSON blob, just type it into a Text Constant - faster. JSON Builder earns its keep when values come from other nodes: a resolution value computed upstream, a filename, a model name. Then the JSON is assembled from live data and stays correct as those values change, which is exactly what you want before handing a payload to an API call node.
Install
Part of MithrilNodes: ComfyUI Manager → Install Custom Nodes → search Mithril ("Mithril-Nodes for ComfyUI"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/MithrilMan/ComfyUI-MithrilNodes
Restart after. No requirements.txt, no model downloads. The pack is young (0.1.0) and its README is a placeholder, so the frontend behavior described above is your best documentation - the source is small enough to read if you hit something unexpected.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| max_depth | INT | 30–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| json_string | STRING | — |