Skip to main content
Bun provides a browser- and Node.js-compatible console global. This page only documents Bun-native APIs.

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
The CLI flag takes precedence over the configuration file setting.

Reading from stdin

In Bun, the console object is also an AsyncIterable that reads process.stdin line by line.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35badder.ts
Use this for interactive programs, like the following addition calculator.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35badder.ts
To run the file:
terminal