Answer: Use `--output-format json` together with `--json-schema` and a JSON Schema definition; the structured output appears in the `structured_output` field. Status: Confirmed Entry: tool/claude-code/agents-and-automation/structured-output Revision: 4 Digest: sha256:ff3afff623bc965a (changes whenever the content changes) Timeline: Created: 2026-11-13T12:10:52Z Last changed: 2026-11-20T12:21:13Z (default output format: — → text) Last verified: 2026-11-20T12:21:13Z Next check: 2026-11-21T12:21:13Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of output format flag | --output-format json | [1] | 2026-11-20 schema flag | --json-schema | [1] | 2026-11-20 structured output field | structured_output | [1] | 2026-11-20 default output format | text | [1] | 2026-11-20 Sources: [1] Anthropic. "Run Claude Code programmatically". https://code.claude.com/docs/en/headless.md Role: primary. Accessed: 2026-11-20T12:21:13Z Quote: "use `--output-format json` with `--json-schema` and a [JSON Schema](https://json-schema.org/) definition" (Supports: output format flag, schema flag) Quote: "with the structured output in the `structured_output` field" (Supports: structured output field) Quote: "`text` (default): plain text output" (Supports: default output format) Published: 2026-11-20T02:53:01Z Snapshot SHA-256: eae22eba29efbd00b5b2592bd64774ffd337ad0efe7645c4c842954c2d9cbcdd (captured 2026-11-20T12:21:14Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:21:13Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:21:13Z Last attempt: 2026-11-20T12:21:13Z Notes and limitations: Extracted automatically from a single official source (section "Get structured output"). Related: https://latestn.com/tool/claude-code/agents-and-automation/structured-output-quick-start How do I get validated JSON structured output from a Claude Code agent? https://latestn.com/tool/claude-code/agents-and-automation/stub-claude-answers-in-test How do I stub what Claude Code would answer in a Claude Code mod test? https://latestn.com/tool/claude-code/agents-and-automation/test-timer-drawing How do I test a timer or a drawing in a Claude Code mod? https://latestn.com/tool/claude-code/agents-and-automation/specify-teammates-models How do I specify teammates and models for a Claude Code agent team? https://latestn.com/tool/claude-code/agents-and-automation/streamevent-reference What StreamEvent types does the Claude Code Agent SDK emit when streaming? https://latestn.com/tool/claude-code/agents-and-automation/streaming-limitations What are the known limitations of streaming output in the Claude Code Agent SDK? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-20T12:21:13Z | changed | default output format: — → text | [1] 2026-11-20T12:21:13Z | changed | default format: text → — | [1] 2026-11-20T12:21:13Z | changed | json format description: json → — | [1] 2026-11-18T12:16:40Z | changed | default format: — → text | [1] 2026-11-18T12:16:40Z | changed | json format description: — → json | [1] 2026-11-18T12:16:40Z | changed | streaming format: stream-json → — | [1] 2026-11-18T12:16:40Z | changed | json output description: json → — | [1] 2026-11-18T12:16:40Z | changed | default output format: text → — | [1] 2026-11-15T12:21:12Z | recovered | Check succeeded again | — 2026-11-15T12:21:12Z | changed | streaming format: — → stream-json | [1] 2026-11-15T12:21:12Z | changed | json output description: — → json | [1] 2026-11-15T12:21:12Z | changed | default output format: — → text | [1] 2026-11-15T12:21:12Z | changed | default format: text → — | [1] 2026-11-15T12:21:12Z | changed | json format description: json → — | [1] 2026-11-14T12:17:00Z | check-failed | Extraction did not pass verification: answer contains `claude -p "Extract the main function names from auth.py" --output-format json --json-schema '{...}'`, which does not appear in the source | — 2026-11-13T12:10:52Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/structured-output/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/agents-and-automation/structured-output POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/structured-output with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/structured-output?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I get structured output from Claude Code programmatically? Revision 4, last verified 2026-11-20T12:21:13Z. https://latestn.com/tool/claude-code/agents-and-automation/structured-output (accessed 2026-11-21T09:57:01Z). @misc{LatestN_tool_claude_code_agents_and_automation_structured_output_r4, title = {How do I get structured output from Claude Code programmatically?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/structured-output}}, note = {Revision 4; digest sha256:ff3afff623bc965a; last verified 2026-11-20T12:21:13Z; accessed 2026-11-21T09:57:01Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/agents-and-automation/structured-output