Parse LLM JSON Output
Your LLM node talks JSON. This is how you actually catch it.
- *
Every LLM node in ComfyUI eventually hands you the same thing: a string. That's fine when you want the string itself - but the moment you want a model to drive your workflow, you want the structured JSON hiding inside that string, and that's the whole job of Parse LLM JSON Output. Feed it the raw model reply, and it hands you the last JSON object or array it can find. Nothing else.
It comes from Duanyll Nodepack, a grab-bag of LLM, data, and API nodes by one author (duanyll). If you're already using the pack's LlmCreateChat / LlmChatCompletion chain, this is the natural next hop: model text in, structured data out, then you can feed the result into the pack's JsonPathQuery or JsonPathQuerySingle nodes to pull individual fields.
How it works
LLMs are messy, and this node is built for that specifically. Its logic is: look for a markdown fenced block (```json or plain ```) and grab the last one; if there isn't one, scan from the end of the text for the last complete {...} object or [...] array, walking backwards to find its matching opener. Then it parses what it found with json5, which tolerates the stuff models love to emit - trailing commas, // comments, unquoted keys - and falls back to the standard library parser after stripping comments if json5 chokes.
So the realistic failure cases are covered. The model wrapped its answer in fences? Fine. It wrote a paragraph, then dumped JSON at the end? Fine. It put a trailing comma before the closing brace? json5 doesn't care.
Inputs and outputs
One input, one output - this is about as simple as a node gets.
llm_output(STRING) - paste the model's reply, or wire it from any LLM/text node.*(any type) - the parsed Python dict or list. The wildcard socket means it plugs into anything in your graph that accepts an "any" input.
That any-typed output is both the feature and the footgun: ComfyUI won't complain about types even when parsing failed and you got None instead. Your downstream node just silently receives nothing. If a workflow built on this node stops doing things, check for a None.
Install
Grab it through ComfyUI Manager - search Duanyll Nodepack - or clone it manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack
Restart ComfyUI. Manager resolves the Python deps (json5 and jsonpath-ng are the ones that matter here), and nothing downloads at install time - no models, no keys. The pack's README is cookiecutter scaffolding, so don't read it for usage docs; the node behaves exactly as the source does.
Troubleshooting
- Output is
None/ downstream gets nothing. The model's reply genuinely wasn't parseable - it wasn't JSON at all, or it was JSON the node couldn't recover from the tail. Fix it upstream: add "respond with JSON only" to your system prompt. No parser rescues a model that refused to emit JSON. - It grabbed the wrong object. The node takes the last complete JSON value. If the model output two JSON blocks and you wanted the first, that's a prompt problem, not a node problem.
- Node errors on import. This pack is young and low-traffic; if ComfyUI throws loading it, the pack's GitHub issues page is the place to check before you go chasing your own config.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| llm_output | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |