# --output-format Flag

> It picks the shape of what claude -p prints.

**Field:** Artificial Intelligence  
**Category:** Claude Code  
**Also known as:** claude --output-format, --output-format json, stream-json

## Think of it like

It is like you ask for a note, a form or a call. It is the same news each way.

## Definition

--output-format picks the shape of what claude -p prints. text, the default, prints just the answer. json prints one JSON object at the end, with the answer, the session ID and the cost. stream-json prints one JSON line for each event as it happens, so a program can follow the run live.

## Example

Jack's script needs the session ID so it can resume later. It runs claude -p with --output-format json and reads session_id from the result.

## Example code

```bash
claude -p "Summarize this project" --output-format json
```

Get the answer as one JSON object.

## Why it matters

A program can read JSON safely. Plain text has to be guessed at.

## Common mistake

Using stream-json in print mode without --verbose. Claude Code stops with an error until you add it.

## Three principles

- **text.** Just the answer.
- **json.** One object at the end.
- **stream-json.** A line per event.

## Related terms

- [Non-Interactive Mode](https://learn.benibix.com/term/ai/non-interactive-mode)
- [--json-schema Flag](https://learn.benibix.com/term/ai/json-schema-flag)
- [--input-format Flag](https://learn.benibix.com/term/ai/input-format-flag)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)

## Taught in

- [Print Mode Output Flags](https://learn.benibix.com/learn/ai-claude-code-commands/print-mode-output-flags): Claude Code Commands, 14/17

![One answer, three shapes: text, one json object at the end, or a stream-json line per event.](https://learn.benibix.com/diagrams/flag-output-format.svg)

---

Source: https://learn.benibix.com/term/ai/output-format-flag
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-16
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
