Simulator
Streams Visualizer
Streams let Node.js process data piece by piece instead of loading everything into memory. Watch chunks flow through pipes, get transformed mid-flight, and see backpressure keep fast producers in check.
Piping a 64 KB file
readable.pipe(writable) — 8 KB chunks, one at a time
source.txt
8K
8K
8K
8K
8K
8K
8K
8K
64 KB left to read
.pipe()
destination
0 / 64 KB written
Without streams — fs.readFile
The entire file is buffered into memory before you can touch a single byte. A 2 GB file means 2 GB of RAM.
memory0 KB
With streams — createReadStream
Only one chunk lives in memory at a time. Memory stays flat no matter how big the file is — 64 KB or 64 GB.
memory≈ 0 KB
pipe.js
const fs = require('fs');
fs.createReadStream('source.txt', { highWaterMark: 8 * 1024 })
.pipe(fs.createWriteStream('destination.txt'));
// 8 KB flows at a time — memory stays constant