Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including progress with all npm packages installed. Try it out:

var progress = require("progress")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

progress v2.0.3

Flexible ascii progress bar

Flexible ascii progress bar.


$ npm install progress


First we create a ProgressBar, giving it a format string as well as the total, telling the progress bar when it will be considered complete. After that all we need to do is tick() appropriately.

var ProgressBar = require('progress');

var bar = new ProgressBar(':bar', { total: 10 });
var timer = setInterval(function () {
  if (bar.complete) {
}, 100);


These are keys in the options object you can pass to the progress bar along with total as seen in the example above.

  • curr current completed index
  • total total number of ticks to complete
  • width the displayed width of the progress bar defaulting to total
  • stream the output stream defaulting to stderr
  • head head character defaulting to complete character
  • complete completion character defaulting to "="
  • incomplete incomplete character defaulting to "-"
  • renderThrottle minimum time between updates in milliseconds defaulting to 16
  • clear option to clear the bar on completion defaulting to false
  • callback optional function to call when the progress bar completes


These are tokens you can use in the format of your progress bar.

  • :bar the progress bar itself
  • :current current tick number
  • :total total ticks
  • :elapsed time elapsed in seconds
  • :percent completion percentage
  • :eta estimated completion time in seconds
  • :rate rate of ticks per second

Custom Tokens

You can define custom tokens by adding a {'name': value} object parameter to your method (tick(), update(), etc.) calls.

var bar = new ProgressBar(':current: :token1 :token2', { total: 3 })
  'token1': "Hello",
  'token2': "World!\n"
bar.tick(2, {
  'token1': "Goodbye",
  'token2': "World!"

The above example would result in the output below.

1: Hello World!
3: Goodbye World!



In our download example each tick has a variable influence, so we pass the chunk length which adjusts the progress bar appropriately relative to the total length.

var ProgressBar = require('progress');
var https = require('https');

var req = https.request({
  host: '',
  port: 443,
  path: '/'

req.on('response', function(res){
  var len = parseInt(res.headers['content-length'], 10);

  var bar = new ProgressBar('  downloading [:bar] :rate/bps :percent :etas', {
    complete: '=',
    incomplete: ' ',
    width: 20,
    total: len

  res.on('data', function (chunk) {

  res.on('end', function () {


The above example result in a progress bar like the one below.

downloading [=====             ] 39/bps 29% 3.7s


To display a message during progress bar execution, use interrupt()

var ProgressBar = require('progress');

var bar = new ProgressBar(':bar :current/:total', { total: 10 });
var timer = setInterval(function () {
  if (bar.complete) {
  } else if (bar.curr === 5) {
      bar.interrupt('this message appears above the progress bar\ncurrent progress is ' + bar.curr + '/' +;
}, 1000);

You can see more examples in the examples folder.




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free