Make console.log messages stand out

Peter Marshall · December 3, 2020

Tomek Sułkowski has shown us a way to make console.log messages stand out in the browser console.

If you add ‘%c’ at the begining of the log message, or anywhere in the message, and then add additional css strings as parameters to the console.log() each additional parameter will format the message with the css you have provided. For reference see - Tomek Sułkowski’s Blog.

so console.log( ‘%c Demo status: %c loaded ‘, background: #6f6; color: #000; padding: 4px; border-radius: 2px);

Will display the message in the console with a nice green background.

Twitter, Facebook