A simple tool that let you synchronously iterate through the lines of a file without loading the whole file in memory.

Usage no npm install needed!

<script type="module">
  import bufferedFileLineReaderSync from 'https://cdn.skypack.dev/buffered-file-line-reader-sync';


Synchroneous, Buffered, Line by Line File Reader

Simple library to read a file line by line, without loading the full file in memory. Ideal to read massive files.


var BufferedFileLineReaderSync = require('buffered-file-line-reader-sync');

var line;
var filename = 'path/to/big/file';

var options = {
    encoding: 'utf8',
    bufferSize: 8192

bufferedReader = new BufferedFileLineReaderSync(filename, options);

while (bufferedReader.hasNextLine()) {


Class: BufferedFileLineReaderSync(path [, options])

  • path: path to the file to read
  • options: object with the following parameters:
    • string encoding (defaults to 'utf8'): any encoding supported by Buffer.toString method of the Buffer node base class.
    • int bufferSize (defaults to 8192): size in octets (bytes) of the underlying buffer used.


Reads the next line in the file. Returns null if done reading.


Returns a boolean value to indicate if all lines have been read.