Claude Structured Output
Get valid JSON out of Claude, every time
- tool
- client
- json_output
- thinking
The name is accurate for once: this node forces Claude to hand back valid JSON that matches a schema you define, instead of the usual "here's a JSON-ish blob inside a paragraph" that makes the rest of your workflow fall over. If you've ever wired a text-generation node into something that needs a number, a color, or a structured list and watched it explode on a stray backtick, this is the fix.
It works through Anthropic's forced tool use. You feed it exactly one tool definition (from the Claude Tool Definition node), and Claude can't "decline" or wrap the output in prose - it must emit a tool call, which the node unwraps into clean JSON. That's the trick that makes it reliable: no post-processing regex, no hoping.
What you set
- prompt - what to extract or generate. "Extract the subject, background, and lighting from this description," that kind of thing.
- tool - the
CLAUDE_TOOLSdefinition. It must contain exactly 1 tool; the node throwsStructured output requires exactly 1 tool definitionif you chain more in. Build it with Claude Tool Definition and wire thetoolsoutput here. - temperature - defaults to 0. The tooltip says it plainly: low values for consistent output, 0.0 recommended. Leave it.
- max_tokens - 4096 default. Your schema's output lives or dies here; if you're extracting a big array, bump it.
- seed - purely a cache-control knob. Randomizing (-1) forces a fresh API call every queue; a fixed value lets ComfyUI reuse a cached result.
The client input is optional - if your Anthropic key lives in Settings > ERPK > API Keys, the node runs standalone. Same for system_prompt: optional, but a good place to set the extraction rules ("return only facts present in the text").
Outputs
Two STRING outputs:
- json_output - the valid JSON, ready for any JSON-parse node or straight into a text consumer.
- thinking - Claude's reasoning, if the model produced any. Nice for debugging why it answered a certain way; ignore it in production.
Installing it
This is one of ~40 nodes in the ERPK Collection by eRepublik-Labs. The cleanest path is ComfyUI Manager → Install Custom Nodes → search erpk → ERPK Custom Nodes. Manually it's:
cd ComfyUI/custom_nodes
git clone https://github.com/eRepublik-Labs/comfyui-nodes-erpk.git erpk
cd erpk && pip install -r requirements.txt
Then restart ComfyUI. No model files to download - this is all API calls. You'll need an Anthropic key; set it in Settings rather than pasting it into nodes, so it doesn't leak when you share a workflow.
Where people get burned
The "exactly 1 tool" error is the classic one - people chain two definitions and wonder why it fails. And the seed widget is easy to misread as a generation seed; it's only for result caching, so don't expect fixed seeds to pin exact outputs. If your JSON keeps coming back truncated, raise max_tokens before you blame the schema.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Prompt describing what to extract or generate | |
| tool | CLAUDE_TOOLS | Tool definition (must contain exactly 1 tool) | |
| seed | INT | -1-1–2147483647 | Seed for cache control. Randomizes by default to ensure fresh results each run. |
| clientopt | CLAUDE_API_CLIENT | Claude API client (optional if API key is configured in Settings) | |
| system_promptopt | STRING | Optional system prompt to guide extraction behavior | |
| temperatureopt | FLOAT | 0.000–1 | Low values for consistent output (0.0 recommended) |
| max_tokensopt | INT | 4096256–8192 | Maximum tokens for the response |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| json_output | STRING | — |
| thinking | STRING | — |