# outputFormat Option

> The option that makes the agent end with JSON in a shape you pick.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** output_format, Agent SDK structured output, Claude Agent SDK outputFormat

## Think of it like

It is like a form to fill in, not a blank page.

## Definition

outputFormat is the Agent SDK option that asks for the final answer as JSON in a shape you set. In Python it is output_format. You give it a JSON Schema, often made with Zod or Pydantic. The agent can use any tools on the way. The result message then holds the checked data. If no valid answer comes after retries, the run ends with an error.

## Example

Mia's agent searches the web for recipes. With outputFormat, each result comes back as an object with a title, a time and a list of steps.

## Example code

```typescript
outputFormat: {
  type: "json_schema",
  schema: { type: "object", properties: { title: { type: "string" } } },
}
```

Ask for an object with a title field.

## Why it matters

Code can use typed data at once. Free text has to be parsed, and parsing breaks.

## Common mistake

Reading the result text field. The checked data sits in its own field, called structured_output.

## Three principles

- **Your JSON shape.** A schema.
- **Tools still allowed.** On the way.
- **Read structured_output.** On success.

## Related terms

- [Structured Output (LLM)](https://learn.benibix.com/term/ai/structured-output)
- [--json-schema Flag](https://learn.benibix.com/term/ai/json-schema-flag)
- [Result Subtype](https://learn.benibix.com/term/ai/result-subtype)

---

Source: https://learn.benibix.com/term/ai/output-format-option
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
