Skip to content
BENIBIX Learn

--input-format Flag

Also known as claude --input-format, --input-format stream-json, --replay-user-messages

It sets how claude -p reads what you send it.

Think of it like

It is like you pass notes to a friend one at a time. You do not send one big letter.

Example

Jack's chat app keeps one Claude run open. Each time the user types, the app sends one JSON line in, and reads the reply lines that come out.

Why it matters

One run can take many messages, so an app does not start a new session for each one.

Definition

--input-format sets how claude -p reads what you send it. text, the default, reads one prompt. stream-json reads one JSON message per line, so a program can keep sending messages into the same run. It goes with --output-format stream-json. Add --replay-user-messages to have each message echoed back once it is taken.

Example code

bash
claude -p --input-format stream-json --output-format stream-json --verbose
Talk to one run in JSON lines, both ways.
--input-format stream-json feeds lines in; the stream on the right comes out.

Common mistake

Sending plain text lines with stream-json set. Each line has to be a JSON message.

Key takeaways

  1. 1
    text. One prompt.
  2. 2
    stream-json. A message per line.
  3. 3
    --replay-user-messages. Echo each one back.

Learn it properly