Skip to main content
On this page

@std/io

Unstable

This @std package is experimental and its API may change without a major version bump.

Overview Jump to heading

Utilities for working with Deno's readers, writers, and web streams.

Reader and Writer interfaces are deprecated in Deno, and so many of these utilities are also deprecated. Consider using web streams instead.

import { toReadableStream, toWritableStream } from "@std/io";

await toReadableStream(Deno.stdin)
  .pipeTo(toWritableStream(Deno.stdout));

Add to your project Jump to heading

deno add jsr:@std/io

See all symbols in @std/io on

Tips Jump to heading

  • Prefer Web Streams for new code. Reader/Writer helpers exist mainly for interop and are being phased out.
  • Use toReadableStream/toWritableStream to bridge Deno’s classic IO to streams without buffering everything.
  • Backpressure is automatic with Streams; avoid manual read loops when piping.
  • For text transforms, pair with TextDecoderStream/TextEncoderStream.

Examples Jump to heading

import { toReadableStream, toWritableStream } from "@std/io";

await toReadableStream(Deno.stdin)
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(
    new TransformStream({
      transform(chunk, ctl) {
        ctl.enqueue(chunk.toUpperCase());
      },
    }),
  )
  .pipeThrough(new TextEncoderStream())
  .pipeTo(toWritableStream(Deno.stdout));

Did you find what you needed?

Privacy policy