Bored of console.log?

kvharish profile image K.V.Harish ใƒป1 min read

A useful and fun thing about console.log is that you can add CSS styles to it. You can do it with the help of %c variable which gets replaced with the respective styles passed in as a parameter.

Alt Text

You can revert the style previously applied using another %c with an empty parameter passed in order.

Alt Text

You can be as creative as you like

Alt Text

You can also reuse styles using variables

Alt Text

This feature can really come in handy when you want to differentiate the console logs added at different parts of the code.

Posted on by:

kvharish profile



Frontend developer and aspiring Fullstack developer from India. Loves to have โ˜• any time of the day.


markdown guide

Remember myself reading a blogpost about how credit cards of millions of people were stolen using an npm package for styling console output. Good old days โ˜•๏ธ


I remember reading this as well... Do you know the title? I'd like to read it again

EDIT: nvm i found it medium.com/hackernoon/im-harvestin...


That's ๐Ÿ˜ฑ. Thanks Alex and Andrew for sharing. No better way to emphasise on choosing dependencies smartly and carefully.



   * shortcut helper link to a baked util.inspect
   * @param object
   * @returns {string}
  static inspect(object) {
      util.inspect(object, {
        showHidden: true,
        depth: null,
        colors: true,
        showProxy: true,
        maxArrayLength: null,
        breakLength: 80


** works on front end dev console too **


Has just die. RIP.


Decorating with consoles ๐Ÿฅ


chalk is a good option to go for.


This is awesome debugging my JavaScript will be super fun now. It may take a lot longer but it's worth it!


Wow! I didn't know that!
I think this is a webkit only thing though, as it surely does not work in terminal. Still an awesome trick!


Yes seems like it. Like others suggested you can try Chalk or any other alternatives available.


Yeah that's cool and all but I don't think anyone would ever choose to debug this way just because they might be "bored of console.log"


Ha Ha please do not take the title of this post literally. ๐Ÿ˜ƒ


Wrote this for fun a while ago that uses one tagged template to color both node.js terminals and frontend dev console text - github.com/Skhmt/ttlog