Json Extractor - klinter
Pull one value out of messy LLM JSON
- STRING
If you're wiring an LLM into ComfyUI, you'll recognize the pain this solves: the model hands you a big JSON blob, and you need one field out of it - the enhanced_prompt, the style tag, the negative prompt - before you can feed it to a CLIP encode. Json Extractor - klinter takes a JSON string in, takes a key name, and returns just that value as a clean string. The default key_to_extract is even set to enhanced_prompt, which tells you exactly what workflow the author built this for.
The real value is how much garbage it tolerates on the way in. Raw LLM output is almost never clean JSON: it arrives wrapped in prose, with escaped newlines, single quotes where JSON wants double quotes, trailing commas, and stray text around the object. This node strips it down before parsing. It finds the first { and last }, tries a straight json.loads, then falls through a ladder of fixes - single-to-double quotes, trailing comma removal, escaping raw control characters - before it finally gives up and raises a clear error. Most one-off JSON extractors in ComfyUI just call json.loads and die; this one fights for you.
The error messages are genuinely useful too. If the key isn't found, it tells you which keys are available in the parsed object. If the JSON is unfixable, you get told it's invalid rather than a confusing traceback. That's a small thing that saves real debugging time.
Inputs: json_input (multi-line, the blob) and key_to_extract (single-line, default enhanced_prompt). Output: STRING, which for non-string values gets JSON-serialized back - so extracting a number gives you a stringified number, and extracting an array gives you a JSON string of it. Keep that in mind if you're feeding the result into an integer input: you'll need a number converter after it.
Install is the pack standard: search "Klinter_nodes" in ComfyUI Manager, or cd ComfyUI/custom_nodes && git clone https://github.com/klinter007/klinter_nodes then restart. No requirements.txt, no models, pure stdlib plus the bundled comfy_api. Keep ComfyUI current, as with every node in this pack.
If you've ever copy-pasted a prompt out of a JSON dump by hand, this node is the thing that makes you stop.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| json_input | STRING | — | |
| key_to_extract | STRING | enhanced_prompt | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |