JSON Builder π§±
Build a request body without typing a single brace
- json_object
- json_string
- summary
You're about to POST to an API and the body has to be JSON - which in a node graph means hand-typing a JSON string into a text widget and praying about the quotes. JSON Builder is the escape hatch: four key/value pairs that it assembles into a proper JSON object for you, with automatic type coercion so "5" becomes a number, not the string "5".
Fill in key_1/value_1 through key_4/value_4. Leave a key blank and that slot is skipped. The type coercion is the part that saves you: true/false become booleans, null becomes JSON null, plain numeric strings become int/float, and a value that starts with {, [, or a quoted string is parsed as nested JSON - so a value can itself be an object or array. That's more clever than it sounds: it means the four slots can express a decent chunk of a real API payload without ever touching JSON syntax.
For the cases four slots can't cover, extra_json merges in a larger hand-written JSON object - deeply nested structures, or more fields than four. Keys in extra_json take priority over the four slots on conflict, which is a sane, documented precedence.
Outputs: json_object (the JSON type - wire this directly into HTTP Request's body, or JSON Field Extractor to read values back out), json_string (the same thing serialized, for nodes that want text), and summary for sanity checks.
Where it fits: it's the bookend to the pack's HTTP Request node. HTTP Request's body is a raw text widget - hand-write JSON or feed it JSON from a builder. This node is the builder. The natural loop: JSON Builder β HTTP Request (POST) β Endpoint Poller (wait for the async job) β JSON Field Extractor (pull the result) β Response Saver (write it down). That's a complete API client with zero hand-typed JSON, and JSON Builder is the piece that keeps it that way.
Honest caveats: the four-slot limit plus extra_json is a decent shape, but for a genuinely complex payload - nested arrays of objects, dynamic fields from different branches - you'll end up pasting JSON into extra_json anyway, at which point the builder's value is mostly the coercion. Also, value fields are strings by default, so a value you want to stay a string that happens to look like a number (a zip code, a phone number "555-0100" - fine, dashes save you - but a zero-padded ID like "007") will be coerced to a number. That's a real gotcha: if you need a numeric-looking string to survive, the way around it is a quoted value, which the node then parses as a JSON string. Worth knowing before a payload silently loses its leading zeros.
Security note, same as every Web API node: whatever you assemble here can end up carrying keys to a network call. Keep secrets out of shared workflows.
Install
Part of OmniNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes
Restart ComfyUI, or install "OmniNodes" via ComfyUI Manager. No extra dependencies - standard library only.
Troubleshooting
- Value came out as a number but I wanted a string - coercion is aggressive. Quote the value (
"007") to force a JSON string. - Four slots aren't enough - use
extra_jsonfor the rest; it merges in and wins conflicts. - Object looks empty in downstream - check you filled a
key; a blank key skips the whole slot.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| key_1 | STRING | β | |
| value_1 | STRING | β | |
| key_2 | STRING | β | |
| value_2 | STRING | β | |
| key_3 | STRING | β | |
| value_3 | STRING | β | |
| key_4 | STRING | β | |
| value_4 | STRING | β | |
| extra_jsonopt | STRING | β |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| json_object | JSON | β |
| json_string | STRING | β |
| summary | STRING | β |