# Console (/docs/runtime/console)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 380 · updated: 2026-07-28 -->
Related: [Watch Mode](/docs/runtime/watch-mode.md), [Debugging](/docs/runtime/debugger.md), [REPL](/docs/runtime/repl.md), [bunfig.toml](/docs/runtime/bunfig.md), [File Types](/docs/runtime/file-types.md), [Module Resolution](/docs/runtime/module-resolution.md)

<Note>
  Bun provides a browser- and Node.js-compatible [console](https://developer.mozilla.org/en-US/docs/Web/API/console)
  global. This page only documents Bun-native APIs.
</Note>

***

## Object inspection depth [#object-inspection-depth]

You can configure how deeply `console.log()` prints nested objects:

* **CLI flag**: Use `--console-depth <number>` to set the depth for a single run
* **Configuration**: Set `console.depth` in your `bunfig.toml` to persist it across runs
* **Default**: Objects are inspected to a depth of `2` levels

```js
const nested = { a: { b: { c: { d: "deep" } } } };
console.log(nested);
// Default (depth 2): { a: { b: { c: [Object ...] } } }
// With depth 4: { a: { b: { c: { d: 'deep' } } } }
```

The CLI flag takes precedence over the configuration file setting.

***

## Reading from stdin [#reading-from-stdin]

In Bun, the `console` object is also an `AsyncIterable` that reads `process.stdin` line by line.

```ts adder.ts icon="/icons/typescript.svg"
for await (const line of console) {
  console.log(line);
}
```

Use this for interactive programs, like the following addition calculator.

```ts adder.ts icon="/icons/typescript.svg"
console.log(`Let's add some numbers!`);
console.write(`Count: 0\n> `);

let count = 0;
for await (const line of console) {
  count += Number(line);
  console.write(`Count: ${count}\n> `);
}
```

To run the file:

```bash terminal icon="terminal"
bun adder.ts
Let's add some numbers!
Count: 0
> 5
Count: 5
> 5
Count: 10
> 5
Count: 15
```
