3

We can stylize console log outputs in browsers. But, how to use the same console.log calls to stylize in command line?

I'm aware of how to colorize console outputs. What I want is: Just calling the below code, it will colorize in CLI automatically; a tool or a way to do that.

Convert CSS to Commandline automatically

console.log('%c COLORFUL', 'background: orange; color: white;');

@Oleg @Bergi this question is not a duplicate. Please read the questions carefully before marking. This question has been marked incorrectly as a duplicate.

Inanc Gumus
  • 25,195
  • 9
  • 85
  • 101

2 Answers2

-1

Have a look at color.js. It provides functions to stylize the console output. Usage is as simple as:

console.log("Yellow text".yellow);
tobspr
  • 8,200
  • 5
  • 33
  • 46
-1

You can use a library, such as chalk.

const chalk = require('chalk');

// combine styled and normal strings
console.log(chalk.blue('Hello') + 'World' + chalk.red('!'));
Oleg
  • 9,341
  • 2
  • 43
  • 58