[BUG] Claude Code CLI returns blank output for --json-schema

Status Fixed / completed
Reported on v2.1.79
Maintainer reply None cached
Activity 4 comments · opened Mar 19, 2026 · closed Mar 21, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When submitting any non-interactive prompt with --json-schema flag, the model appears to call the structured output tool, but the CLI never returns the output.

To reproduce:
claude -p --model sonnet --json-schema '{"type":"object","properties":{"color":{"type":"string"},"count":{"type":"number"}},"required":["color","count"]}' "How many legs does a cat have? Reply with the color of the sky and the number of legs."

Returns zero output.

Transcript from the above query (generated via claude-devtools):

---

Session Export

| Property | Value |
|----------|-------|
| Session | c2a9bad2-78a3-4cb3-96b0-2460816b159a |
| Project | /Users/shXXXXXXXXXXXXXXXXXXXXXXXXX |
| Branch | main |
| Date | 2026-03-19 03:04:16 UTC |

Metrics

| Metric | Value |
|--------|-------|
| Duration | 3s |
| Total Tokens | 31,987 |
| Input Tokens | 3 |
| Output Tokens | 71 |
| Cache Read | 6,341 |
| Cache Created | 25,572 |
| Messages | 3 |
| Cost | N/A |

Conversation

User (Turn 1)

How many legs does a cat have? Reply with the color of the sky and the number of legs.

Assistant (Turn 2)

Tool: StructuredOutput
Input: {
"color": "blue",
"count": 4
}

Structured output provided successfully

Tool: StructuredOutput

{
  "color": "blue",
  "count": 4
}

Result:

Structured output provided successfully

What Should Happen?

Output for the above query should be:

{
"color": "blue",
"count": 4
}

Error Messages/Logs

Steps to Reproduce

Just run the following prompt:

claude -p --model sonnet --json-schema '{"type":"object","properties":{"color":{"type":"string"},"count":{"type":"number"}},"required":["color","count"]}' "How many legs does a cat have? Reply with the color of the sky and the number of legs."

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.79 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

<img width="836" height="327" alt="Image" src="https://github.com/user-attachments/assets/188ddc00-dffa-436e-961c-42943a37f1fc" />

View original on GitHub ↗

4 Comments

github-actions[bot] · 7 months ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/27926

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

shdeen · 7 months ago
Found 1 possible duplicate issue: 1. https://github.com/anthropics/claude-code/issues/27926 This issue will be automatically closed as a duplicate in 3 days. - If your issue is a duplicate, please close it and 👍 the existing issue instead - To prevent auto-closure, add a comment or 👎 this comment 🤖 Generated with Claude Code

Not the same issue. Adjacent, but not the same.

shdeen · 6 months ago

Issue was with the missing '--output-format json' flag. (I thought it was implied in --json-schema. Turns out it's not.)

For anyone encountering the same issue:

Specifying '--output-format json' returns the full structured reply with the full output of all the turns (easily > 10k chars). The actual structured output with the response to the question is in the last array element, with "type": "result", in the "structured_output" property. Piping through jq gets the expected result.

Example:
----------
claude -p --model sonnet --output-format json --json-schema '{"type":"object","properties":{"color":{"type":"string"},"count":{"type":"number"}},"required":["color","count"]}' "How many legs does a cat have? Reply with the color of the sky and the number of legs." | jq '.[] | select(.type == "result").structured_output'

Output:
--------
{
"color": "blue",
"count": 4
}

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.