JsonExtractFloat
Reading cfg and denoise out of a config blob
- FLOAT
JsonExtractFloat is the FLOAT member of this pack's little JSON-reader family. Give it a text blob and a path, get a number you can wire into cfg, denoise, strength, or anything else with a decimal in it. If you're building the "one config file drives the whole workflow" setup - a TOML prompt file whose exports carry cfg, denoise, sampler, scheduler, and then a chain of extract nodes feeding the sampler - this is the one that ferries the decimals across.
How it works
def extract(self, json_text: str, path: str, default: float):
r = json.loads(json_text)
for key in path.split("."):
if key not in r:
return (default,)
r = r[key]
return (float(r),)
The path is dot-separated and walks dict keys, so sampling.cfg digs into {"sampling": {"cfg": 5.0}}. Miss a key anywhere along the route and you get default back - no error. Hit the value and it's coerced with float().
That coercion is friendlier than you'd expect, and it's the reason this node pairs well with a TOML exports block: those values arrive as strings, and float("5.0") is 5.0. Integers coerce too, so steps read through this node still works. What does not work is a non-numeric string - "five" raises - and that failure is a run-time exception rather than a fallback, so a config with a typo'd number is loud while a config with a typo'd key is silent.
Inputs and outputs
json_text (the blob), path (dotted route, tooltip: "period separated path to json value"), default (a FLOAT that covers the missing-key case). One FLOAT output. JsonExtractInt, JsonExtractString and JsonExtractBoolean are the same node at other types.
Install
Manager search for the pack, or:
cd ComfyUI/custom_nodes
git clone https://github.com/morino-kumasan/comfyui-toml-prompt
restart ComfyUI. No dependencies to install - this repo's requirements.txt is empty, and everything it uses is stdlib json plus ComfyUI's own runtime. The README's install block is out of date (old repo name, SSH URL), so use the HTTPS clone above.
Where people get burned
Wiring cfg without thinking about the model. Since this node exists to make config-driven cfg easy, it's worth saying out loud: on a guidance-distilled model at CFG 1 there is no unconditional pass, so your negative prompt is discarded entirely, and it's not the node's fault. Pull cfg from config if you like, but know what the number means before you sweep it.
A default that's wrong for denoise. The default is whatever you type, and if a path typo makes the node fall back to it, a denoise of 1.0 on an img2img pass re-renders from scratch. If your "subtle" second pass is nuking the image, check that the extract actually resolved.
Nested numbers that aren't there. Lists aren't indexed - path only walks dict keys. samplers.0.cfg is not a thing this node can do.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| json_text | STRING | — | |
| path | STRING | period separated path to json value | |
| default | FLOAT | -9223372036854776000–9223372036854776000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| FLOAT | FLOAT | FLOAT. |