Needle Extract (text to JSON)
Free text to JSON, with a schema you actually control
- result
- json
- confidence
- success
- info
The most useful way to think about Needle Extract: it's not an LLM node for the kind of thing you're used to. You're not asking it to write a prompt or chat with you. You paste in some free text - an invoice line, a user request, a filename - define a schema, and it hands you back clean typed JSON with exactly the fields you asked for. "Invoice from Acme Corp for 1200.50 dollars, due 2026-09-01" in, {"vendor": "Acme Corp", "total": 1200.5, "note": ""} out.
Under the hood it's Cactus Needle 2, a 45M-parameter model that runs entirely on your CPU in a 14 MB binary. No GPU, no API key, no VRAM budget to argue with - the README quotes ~0.2–1.5 s per call at 550–840 tok/s prefill. That's the same "small and obedient, not large and clever" niche the KB's LLM-in-ComfyUI essay describes: the job is format-following, and a 45M model built for tool calling is the right size for it. It has a 256-token sliding window and, importantly, no free-text fallback - every answer is structured. If the text has nothing for a field, the field is omitted. It does not hallucinate an invoice when you feed it a recipe. That's the guarantee, and it's the reason to trust it where a chat model would embellish.
The inputs that matter
- text - keep it short. The tooltip is blunt about it: the engine uses a 256-token window, so long input just gets cut.
- schema - three shapes accepted. The shorthand is usually enough:
{"vendor": "string", "total": "number", "note": "string?"}. A trailing?marks the field optional. You can also paste a bare JSON Schema or a full needle tool schema. Field order is load-bearing in the engine's decoding grammar, so put the fields you care about first.
Optional but worth knowing: system (environment facts given to the model), max_new_tokens (16–1024, default 256), drop_ungrounded (default on - discards anything the engine flags as not grounded in the input, instead of handing you a guess), and weights (a path to a finetuned .cact file - read the warning below before you touch this one).
Outputs
result is the NEEDLE_RESULT object (wire it into Needle Get Field). json is the same thing as pretty-printed STRING. confidence is a FLOAT. success is a BOOLEAN - true only when fields actually matched. info is a STRING with a human-readable rundown: which fields matched, what got dropped as ungrounded, engine stats.
The README's measured honesty applies: extraction from prose is good, and the model correctly returns {} on off-topic text. But the confidence score is not a reliability meter - correct answers have come back at 0.00 and wrong ones at 0.65. Treat it as a backstop, not a verdict. And it's English-only in practice; German input produced no call at all where the English equivalent scored 0.996.
Install
ComfyUI Manager - search ComfyUI Needle 2 - or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/DenRakEiw/Comfyui_Needle2
python_embeded\python.exe -m pip install cactus-needle
Then restart ComfyUI. First run downloads the 14 MB engine binary into ~/.cache/cactus-needle/. Two gotchas from the README, both real:
- Don't name the folder
needle. The engine's own Python package is calledneedle, and any custom node pack that putscustom_nodesonsys.pathwill import your folder instead - every node fails with a clear error telling you to rename.Comfyui_Needle2is safe. - Windows Smart App Control can block the unsigned DLL with
OSError: [WinError 4551]. Fixing it means turning Smart App Control off, which is irreversible.
And the weights gotcha: a loaded .cact finetune cannot be unloaded. Once one is loaded, every base-model node in the process fails. Don't point it at a finetune casually.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | Text to extract from. Keep it short - the engine uses a 256-token window. | |
| schema | STRING | { "subject": "string", "style": "string?", "width": "integer?", "height": "integer?" } | Shorthand {"field": "string"}, a bare JSON Schema, or a full needle tool schema. Suffix a type with ? to make it optional. |
| systemopt | STRING | Environment facts given to the model. | |
| max_new_tokensopt | INT | 25616–1024 | — |
| drop_ungroundedopt | BOOLEAN | true | Discard fields the engine flags as not grounded in the input text. |
| weightsopt | STRING | Optional path to a finetuned .cact file. The engine cannot unload weights, so once one is loaded every base-model node in the process will fail. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| result | NEEDLE_RESULT | — |
| json | STRING | — |
| confidence | FLOAT | — |
| success | BOOLEAN | — |
| info | STRING | — |