XB-llama - 📋 解析JSON
Pull one value out of your LLM's JSON without a Python node
- any
- string
- int
- float
- boolean
Local LLMs love to answer in JSON, and ComfyUI loves typed values. The glue between them is XB_llamaParseJSON - give it a JSON string and a dotted key path, and it hands you that value as a string, an int, a float, and a boolean all at once. No Python node, no regex spaghetti, no manual copy-paste.
The shape of the node is borrowed from the Crystools pack (the source says so directly), and the design is smart about the mess real LLM output is in: it strips ```json code fences automatically before parsing, so you can feed it the raw completion output and skip a cleaning step.
The inputs
- input - the
STRINGwire with your JSON. It also accepts a list of JSON strings (each gets parsed). - key - the dotted path to the value you want, e.g.
bboxes.0.labelorshots.2.duration_sec. Required - leave it empty and the node errors rather than guessing. - default - what to return when the key doesn't exist. Optional, but genuinely useful: an LLM that skips a field won't crash your workflow, it'll just fill in the default.
The outputs
Five sockets, all representing the same extracted value:
- any - the raw value (could be any JSON type - string, number, bool, even a nested object).
- string - the value coerced to text.
- int - numeric value as an integer (non-numeric values pass through as-is rather than erroring).
- float - numeric value as a float.
- boolean - the value interpreted as truthy (
"true"/"false"strings handled correctly).
You wire whichever socket matches what the downstream node expects. This is the "key" step in a lot of LLM-driven flows: parse the LLM's answer, pull the one field you need, feed it into a primitive or a parameter node.
Installing it
Part of XB_ToolBox - ComfyUI Manager (XB_ToolBox) or:
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
restart, done. Zero dependencies - this is pure JSON plumbing and works even if you never install llama-cpp-python (feed it JSON from any source, not just the llama nodes).
The gotchas
The error message when key is empty - Key 不能为空! - is in Chinese, so if you're staring at a red node wondering what you missed, that's it. Also: input is marked forceInput, meaning you can't type JSON in the widget; it must arrive over a wire. And the nested-path parsing is simple dot traversal - it handles a.b.c fine, but it won't do array wildcards or JSONPath, so if you need "the second element of every item," you'll want a proper code node instead. Keep the paths literal and you're good.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input | STRING | — | |
| keyopt | STRING | — | |
| defaultopt | STRING | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| any | * | — |
| string | STRING | — |
| int | INT | — |
| float | FLOAT | — |
| boolean | BOOLEAN | — |