Nodes/ERPK Collection/Claude Structured Output
ComfyUI Node

Claude Structured Output

Get valid JSON out of Claude, every time

By eRepublik-Labs·Created 11 months ago·Updated 21 days ago· 1
Claude Structured Output
  • tool
  • client
  • json_output
  • thinking
prompt
seed-1
system_prompt
temperature0.00
max_tokens4096

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_TOOLS definition. It must contain exactly 1 tool; the node throws Structured output requires exactly 1 tool definition if you chain more in. Build it with Claude Tool Definition and wire the tools output 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 erpkERPK 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.

CategoryERPK/Claude/Tools

Inputs (7)

NameTypeDefaultDescription
promptSTRINGPrompt describing what to extract or generate
toolCLAUDE_TOOLSTool definition (must contain exactly 1 tool)
seedINT-1-1–2147483647Seed for cache control. Randomizes by default to ensure fresh results each run.
clientoptCLAUDE_API_CLIENTClaude API client (optional if API key is configured in Settings)
system_promptoptSTRINGOptional system prompt to guide extraction behavior
temperatureoptFLOAT0.000–1Low values for consistent output (0.0 recommended)
max_tokensoptINT4096256–8192Maximum tokens for the response

Outputs (2)

NameTypeDescription
json_outputSTRING
thinkingSTRING