JSON Text Extraction
Pick values out of LLM JSON and pipe them into the graph
- STRING
- STRING
- STRING
- STRING
This is the node that makes LLM output usable in ComfyUI. The pack's Claude and Nova LLM nodes return text, and when you ask an LLM for structured data, you get JSON. That JSON is useless sitting in a string - this node cracks it open and hands you up to four individual values as plain STRING outputs you can wire anywhere.
How it works
It's delightfully simple under the hood: parse the JSON with json.loads, then for each key you name, look it up with .get(). No API call, no AWS involvement - despite the node living in the "aws" category of a Bedrock pack, the only thing it touches is a string.
You feed it a json_text (the JSON string, usually from an LLM node's output) and up to four optional key inputs: key1, key2, key3, key4. Each key is the JSON field name you want to extract. So if an LLM returns:
{"prompt": "a red fox in snow", "negative": "blurry", "seed": 42}
you set key1 to prompt, key2 to negative, key3 to seed, and the four STRING outputs carry each value. Missing keys don't error - they come back as an empty string, which is friendly for partial responses and dangerous if you forget to check.
What to wire it into
The outputs are plain strings, so they go anywhere text goes: a prompt input on a Nova Canvas or Stability node, a seed input, a Prompt Template placeholder, a filename prefix for saving. That's the whole point of the pack's fancier workflows - an LLM thinks about your prompt, returns structured JSON, and this node turns that structure into values the rest of the graph can consume. The pack's example workflows use exactly this pattern to have Claude refine a prompt and hand the result to an image model.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/aws-samples/comfyui-llm-node-for-amazon-bedrock.git
pip install -r comfyui-llm-node-for-amazon-bedrock/requirements.txt
Restart ComfyUI (or ComfyUI Manager → "Amazon Bedrock"). Dependencies are boto3, requests, retry - nothing heavy, and nothing here needs an AWS account even if you only use this node.
Where people get burned
- Fenced JSON breaks it. Many LLMs wrap JSON in markdown code fences (
```json).json.loadschokes on that. Strip the fences first - conveniently, the pack's "Prompt Regex Remove" node can do exactly that, which is probably why both ship together. - Keys must match exactly.
data.get("prompt", "")is case-sensitive and whitespace-sensitive. If the LLM returnsPromptand you ask forprompt, you get an empty string, silently. - It's not JSON-path aware.
data.key.subkeystyle nesting isn't supported - only top-level fields. For nested values, extract the outer object and parse again. - Invalid JSON hard-fails. A malformed string raises and the node errors out rather than returning anything partial.
One honest caveat: like most of this pack, it's sample-grade code from an official AWS repo last touched around early 2025. It does one tiny job and does it fine. If you need deeper JSON extraction, the community has fancier JSON-path nodes - this one is for the 90% case.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| json_text | STRING | — | |
| key1opt | STRING | — | |
| key2opt | STRING | — | |
| key3opt | STRING | — | |
| key4opt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |
| STRING | STRING | — |
| STRING | STRING | — |
| STRING | STRING | — |