Nodes/ComfyUI-LLMs-Toolkit/JSON Builder Medium
ComfyUI Node

JSON Builder Medium

Five clean key-value pairs without the quote drama

By ComfyUI-Kelin·Created 2 years ago·Updated 4 months ago· 27
JSON Builder Medium
    • json_string
    key_1
    key_2
    key_3
    key_4
    key_5
    value_1
    value_2
    value_3
    value_4
    value_5

    The workhorse of the JSON Builder family

    JSON Builder Medium builds a JSON object from up to five key-value pairs. It's the middle child of ComfyUI-LLMs-Toolkit's Simple/Medium/Large trio, and in practice it's the one most workflows actually need: a handful of structured fields - say subject, style, lighting, camera, negative - destined for a String Template that turns them into a prompt, or a JSON Combine that merges them with other blocks. Five pairs is enough for real structure without the sprawling node that the Large variant becomes.

    It does exactly one thing and does it cleanly. The keys are typed in (fields key_1 through key_5, all required inputs with empty defaults), the values (value_1 through value_5) can be typed or wired in from other nodes, and out the other side comes one pretty-printed JSON string. No schema, no validation beyond "is this empty" - it's a formatter, and that's its virtue.

    The bit that's easy to miss

    Values are parsed as JSON before being written. Type 5 and the output contains the number 5; type true, null, or a nested {"x": 1} and they're preserved as native JSON types. That's what makes the output genuinely usable downstream - an LLM API or another JSON node sees real structure, not quoted strings. It also means you can construct nested objects by connecting another builder's output into a value slot.

    Inputs and output

    • key_1 … key_5 (required) - property names; blank keys are skipped.
    • value_1 … value_5 (optional) - matching values, JSON-parsed, connectable.
    • Output: json_string - {"a": 1, "b": "two", ...}, indented two spaces.

    Installing

    It's one of twelve nodes in the HuangYuChuh/ComfyUI-LLMs-Toolkit pack - install the pack once. ComfyUI Manager → search ComfyUI-LLMs-Toolkit → Install → restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/HuangYuChuh/ComfyUI-LLMs-Toolkit
    cd ComfyUI-LLMs-Toolkit
    pip install -r requirements.txt
    

    You'll find it under 🚦ComfyUI_LLMs_Toolkit/JSON. The pack's only dependencies are Pillow and aiohttp.

    Gotchas

    Mostly the same rules as its Simple sibling: empty keys or values are dropped silently (you won't get empty strings in the output), and values that fail JSON parsing fall back to plain strings. One real annoyance: if you only need two pairs, you still have to look at five key boxes - they're required inputs, so ComfyUI shows them all. That's fine, just leave the extras blank and they contribute nothing. If five isn't enough, jump to JSON Builder Large (ten pairs) or build blocks with this and merge them with JSON Combine.

    Category🚦ComfyUI_LLMs_Toolkit/JSON

    Inputs (10)

    NameTypeDefaultDescription
    key_1STRING
    key_2STRING
    key_3STRING
    key_4STRING
    key_5STRING
    value_1optSTRING
    value_2optSTRING
    value_3optSTRING
    value_4optSTRING
    value_5optSTRING

    Outputs (1)

    NameTypeDescription
    json_stringSTRING