Skip to main content

What does "I/O" mean in the context of Node.js?

In the context of Node.js, the term I/O stands for Input/Output, meaning data going in and out. It's a general label for any operation involving a program interacting with the outside world:

  • reading and writing files (via fs),
  • database queries,
  • network requests (HTTP, TCP, WebSocket, and so on),
  • console or user interactions.

The core idea:

Node.js is built around non-blocking (asynchronous) I/O. That means when a program does, say, a file read or an HTTP request, it doesn't wait for the operation to finish, instead:

  1. It starts the operation (for example, reading a file);
  2. It hands control back;
  3. Once the operation finishes, a callback, Promise, or async/await handles the result.

Example:

javascript
const fs = require('fs'); // Asynchronous (non-blocking) file read: fs.readFile('data.txt', 'utf8', (err, data) => { if (err) throw err; console.log(data); }); console.log('This log prints before the file's content does');

Here, Node.js doesn't wait for the file read to finish, it keeps running the rest of the code, an example of asynchronous I/O.

Why this matters:

  • It doesn't block the execution thread.
  • It lets Node.js serve thousands of concurrent requests.
  • It's the foundation of high performance for network and file work.

Summary:

I/O (Input/Output) in Node.js covers input/output operations (files, network, databases, and so on), implemented asynchronously and non-blockingly, to make the most of a single-threaded architecture.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.