Command Line Progress Bar

3.12.0 · active · verified Wed Apr 22

cli-progress is a robust and highly customizable library for displaying interactive progress bars in Node.js command-line and terminal applications. Currently stable at version 3.12.0, it sees active development with several releases per year, ensuring continuous improvement and bug fixes. Key features include full control over output formatting, support for both single and multiple concurrent progress bars, and the ability to define custom tokens for displaying additional data (payloads). It offers various presets for quick styling and operates without requiring callbacks, being designed as an externally controlled UI widget suitable for both asynchronous and synchronous tasks. Unlike many alternatives, its focus on external control provides flexibility, and it includes features like FPS limiting and TTY/NOTTY mode handling.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates a single progress bar with custom formatting, colors (using 'ansi-colors'), and a dynamic payload token update.

const cliProgress = require('cli-progress');
const colors = require('ansi-colors'); // Install 'ansi-colors' manually: npm install ansi-colors

// Create new progress bar instance
const b1 = new cliProgress.SingleBar({
    format: 'CLI Progress |' + colors.cyan('{bar}') + '| {percentage}% || {value}/{total} Chunks || Speed: {speed}',
    barCompleteChar: '\u2588',
    barIncompleteChar: '\u2591',
    hideCursor: true
});

// Initialize the bar with total 200, start value 0, and a custom payload token 'speed'
b1.start(200, 0, {
    speed: "N/A"
});

let value = 0;
const timer = setInterval(() => {
    value += 5;
    b1.update(value, { speed: `${(Math.random() * 10).toFixed(2)} MB/s` });

    if (value >= b1.getTotal()) {
        clearInterval(timer);
        b1.stop();
        console.log('Progress complete!');
    }
}, 100);

view raw JSON →