2

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
  • 21,395
  • 9
  • 79
  • 93

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
  • 7,920
  • 3
  • 29
  • 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,131
  • 2
  • 44
  • 56