Skip to main content
For CLI tools, it’s often useful to read from stdin. In Bun, the console object is an AsyncIterable that yields lines from stdin.
index.ts

Running this file results in a never-ending interactive prompt that echoes whatever the user types.
terminal

Bun also exposes stdin as a BunFile via Bun.stdin. This is useful for incrementally reading large inputs that are piped into the bun process. There is no guarantee that the chunks will be split line-by-line.
stdin.ts

This will print the input that is piped into the bun process.
terminal

See Docs > API > Utils for more useful utilities.