JSON -> Vars (Editable)
Any JSON becomes {{mustache}} variables, flat or nested
- vars_in
- vars
- obj
The pack's chat nodes let you write {{var}} in any prompt, but where do the vars come from? JSON -> Vars (Editable) is the node that bridges the gap between "LLM gave me a JSON blob" and "my prompt references named variables." It takes any JSON object and converts it into a SIMPLECHAT_VARS dict, so {"character": "Aiko", "hair": "blonde"} becomes {{character}} and {{hair}} you can drop into prompts, system messages, or Mustache templates. It's the generic version of the fixed-schema unpacking the pack's Prompt JSON Unpack does.
The knobs
json_text- the JSON (fences auto-stripped viastrip_code_fence).flatten_keys(default on) - turns nested objects into dotted keys:{"character": {"hair": "blonde"}}becomes{{character.hair}}, and arrays become{{tags[0]}}. Turn it off and only top-level keys are exposed.prefix- optional namespace, soanimamakes{{anima.positive}}. Handy when you're merging multiple sources and don't want name collisions.overrides- manualkey=valuelines (orkey: value), applied last so you can pin or fix a value by hand.override_mode-vars_in_overrides_json(default, incoming vars win over JSON) vsjson_overrides_vars_in(JSON wins). Picks which side of the merge is boss.vars_in- optional incoming vars to merge with.
Outputs: vars (the SIMPLECHAT_VARS dict) and obj (the parsed JSON as SIMPLECHAT_JSON for other consumers). The parser is forgiving - it strips fences, removes trailing commas, and as a last resort extracts the first {...} block from surrounding prose, which is exactly the messy output an LLM produces.
The workflow shape
Chat returns JSON → this node → vars into the next Chat node's vars input → that chat's prompt uses {{character}} freely. Or take a JSON from JSON Parse's obj port and turn it into template variables without re-parsing. Because prefix gives you namespacing, you can pipe an Anima prompt JSON in as anima.* while a settings JSON comes in unprefixed, and both coexist in one prompt.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/Moeblack/ComfyUI-SimpleChat
Restart, or use Manager and search "ComfyUI-SimpleChat". Only dep: aiohttp.
Gotchas
Values that are objects or arrays get stringified to JSON text when flattening is off - so {{tags}} with a list becomes ["a", "b"] in your prompt, not a comma-joined list. If you want readable joins, flatten on and reference {{tags[0]}} individually, or do the joining in the LLM before it outputs. And the top-level JSON must be an object; a bare array at the root raises "Expected a JSON object (dict) at top-level."
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| json_text | STRING | — | |
| strip_code_fence | BOOLEAN | true | — |
| flatten_keys | BOOLEAN | true | Flatten nested keys into a.b.c and arr[0] style keys. |
| prefix | STRING | Optional prefix, e.g. anima. (will become prefix.key) | |
| override_mode | COMBO | vars_in_overrides_json | 2 options: vars_in_overrides_json, json_overrides_vars_in |
| overrides | STRING | — | |
| vars_inopt | SIMPLECHAT_VARS | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| vars | SIMPLECHAT_VARS | — |
| obj | SIMPLECHAT_JSON | — |