Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Node.js How to read a large JSON file line by line (without completely loading it in memory)

My JSON file is very large to do this in memory (≈ 500MB) and there will be more than one files that I should read concurrently. Is there any way that I can do this in Node.js ? (with or without any external libraries)

const searchStream = (path, text = '') => new Promise((resolve, reject) => {
  const inStream = fs.createReadStream(path);
  const outStream = new Stream();
  const rl = readline.createInterface(inStream, outStream);
  const result = [];
  let count = 0;
  const regEx = new RegExp(text, 'i');
  rl.on('line', (line) => {
    if (line && line.search(regEx) >= 0) {
      count++;
      result.push(line);
    }
  });
  rl.on('close', () => {
    resolve({
      result,
      count,
    });
  });
  rl.on('error', (err) => {
    reject(err);
  });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!