# Read from stdin (/guides/process/stdin)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 316 · updated: 2026-07-28 -->
Related: [Parse command-line arguments](/guides/process/argv.md), [Listen for CTRL+C](/guides/process/ctrl-c.md), [Spawn a child process and communicate using IPC](/guides/process/ipc.md), [Get the process uptime in nanoseconds](/guides/process/nanoseconds.md), [Listen to OS signals](/guides/process/os-signals.md), [Read stderr from a child process](/guides/process/spawn-stderr.md)

In Bun, the `console` object is an `AsyncIterable` that yields lines from `stdin`.

```ts icon="/icons/typescript.svg" title="index.ts"
const prompt = "Type something: ";
process.stdout.write(prompt);
for await (const line of console) {
  console.log(`You typed: ${line}`);
  process.stdout.write(prompt);
}
```

***

Running this file starts a never-ending interactive prompt that echoes whatever you type.

```sh icon="terminal" title="terminal" terminal
bun run index.ts
```

```txt
Type something: hello
You typed: hello
Type something: hello again
You typed: hello again
```

***

Bun also exposes `stdin` as a `BunFile`, `Bun.stdin`. Use it to incrementally read large inputs piped into the `bun` process.

Chunks aren't guaranteed to be split line-by-line.

```ts icon="/icons/typescript.svg" title="stdin.ts"
for await (const chunk of Bun.stdin.stream()) {
  // chunk is Uint8Array
  // this converts it to text (assumes ASCII encoding)
  const chunkText = Buffer.from(chunk).toString();
  console.log(`Chunk: ${chunkText}`);
}
```

***

Running `stdin.ts` prints whatever is piped into it.

```sh icon="terminal" title="terminal" terminal
echo "hello" | bun run stdin.ts
```

```txt
Chunk: hello
```

***

See [Utils](/runtime/utils) for more utilities.
