Sometimes, we want to change a Node.js’s console font color.
In this article, we’ll look at how to change a Node.js’s console font color.
How to change a Node.js’s console font color?
To change a Node.js’s console font color, we can call console.log
with the color code we want for the text.
For instance, we write
console.log('x1b[36m%sx1b[0m', 'I am cyan');
console.log('x1b[33m%sx1b[0m', stringToMakeYellow);
to print cyan and yellow text respectivelt.
The first string argument is the color code.
The list of color codes and text styles include
Reset = "x1b[0m"
Bright = "x1b[1m"
Dim = "x1b[2m"
Underscore = "x1b[4m"
Blink = "x1b[5m"
Reverse = "x1b[7m"
Hidden = "x1b[8m"
Foreground Black = "x1b[30m"
Foreground Red = "x1b[31m"
Foreground Green = "x1b[32m"
Foreground Yellow = "x1b[33m"
Foreground Blue = "x1b[34m"
Foreground Magenta = "x1b[35m"
Foreground Cyan = "x1b[36m"
Foreground White = "x1b[37m"
Background Black = "x1b[40m"
Background Red = "x1b[41m"
Background Green = "x1b[42m"
Background Yellow = "x1b[43m"
Background Blue = "x1b[44m"
Background Magenta = "x1b[45m"
Background Cyan = "x1b[46m"
Background White = "x1b[47m"
Conclusion
To change a Node.js’s console font color, we can call console.log
with the color code we want for the text.