Answer: You can use Zod (TypeScript) or Pydantic (Python) to define your schema, and these libraries generate the JSON Schema for you. For Zod, pass `target: "draft-7"` when converting your schema because the SDK validates schemas with JSON Schema draft-07. Status: Confirmed Entry: tool/claude-code/agents-and-automation/zod-pydantic-schemas Revision: 1 Digest: sha256:fa67df89ef1a4f41 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:03:01Z Last changed: 2026-11-13T03:03:01Z Last verified: 2026-11-20T12:17:27Z Next check: 2026-11-21T12:17:27Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of Libraries | Zod | [1] | 2026-11-20 Zod target option | target: "draft-7" | [1] | 2026-11-20 JSON Schema draft | draft-07 | [1] | 2026-11-20 Zod default draft | draft 2020-12 | [1] | 2026-11-20 Sources: [1] Anthropic. "Get structured output from agents". https://code.claude.com/docs/en/agent-sdk/structured-outputs.md Role: primary. Accessed: 2026-11-20T12:17:27Z Quote: "you can use [Zod](https://zod.dev/) (TypeScript) or [Pydantic](https://docs.pydantic.dev/latest/) (Python) to define your schema" (Supports: Libraries) Quote: "pass `target: "draft-7"` when converting your schema" (Supports: Zod target option) Quote: "The SDK validates schemas with JSON Schema draft-07, so schemas that declare a newer version are rejected." (Supports: JSON Schema draft) Quote: "Zod targets draft 2020-12 by default" (Supports: Zod default draft) Published: 2026-11-20T02:57:54Z Snapshot SHA-256: e9e1254217642a03b1b5dc046b43102443b7c7cfcfc3c0590efb9468f8b5ae75 (captured 2026-11-13T03:03:01Z) 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]. On this check the text of [1] was unchanged since 2026-11-13T03:03:01Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T12:17:27Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:17:27Z Last attempt: 2026-11-20T12:17:27Z Notes and limitations: Extracted automatically from a single official source (section "Type-safe schemas with Zod and Pydantic"). Related: https://latestn.com/tool/claude-code/commands-and-shortcuts/available-actions-contexts Which keyboard shortcut contexts and actions are available in Claude Code? https://latestn.com/tool/claude-code/commands-and-shortcuts/chain-multiple-skills How do I chain multiple skills in one message in Claude Code? https://latestn.com/tool/claude-code/commands-and-shortcuts/clear-goal How do I clear or cancel an active goal in Claude Code? https://latestn.com/tool/claude-code/agents-and-automation/when-to-use-single-message-input When should I use single message input instead of streaming input in the Claude Agent SDK? https://latestn.com/tool/claude-code/agents-and-automation/write-eval-case How do I write an eval case for a Claude Code plugin, including prompt.md frontmatter and case.yaml fields? https://latestn.com/tool/claude-code/agents-and-automation/write-mod-test How do I write an automated test for a Claude Code mod? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:03:01Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/agents-and-automation/zod-pydantic-schemas/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/zod-pydantic-schemas POST: https://latestn.com/dispute/tool/claude-code/agents-and-automation/zod-pydantic-schemas with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/agents-and-automation/zod-pydantic-schemas?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I define a type-safe schema with Zod or Pydantic for Claude Code structured outputs? Revision 1, last verified 2026-11-20T12:17:27Z. https://latestn.com/tool/claude-code/agents-and-automation/zod-pydantic-schemas (accessed 2026-11-21T10:08:26Z). @misc{LatestN_tool_claude_code_agents_and_automation_zod_pydantic_schemas_r1, title = {How do I define a type-safe schema with Zod or Pydantic for Claude Code structured outputs?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/agents-and-automation/zod-pydantic-schemas}}, note = {Revision 1; digest sha256:fa67df89ef1a4f41; last verified 2026-11-20T12:17:27Z; accessed 2026-11-21T10:08:26Z} } 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/zod-pydantic-schemas