×

How to style console.log() in JavaScript

Hello Devs,

Is it possible to style console.log() in JavaScript ? Its YES.

Have you ever tried this ? If No, then lets do it together in these 2 simple steps.

  1. Add %c before the text you want to style.
  2. Insert one more argument in the console log function with the style you want to apply.

Do Checkout some of these examples:

console.log(`I LOVE 💜 %c${name}`, "color: green");

will produce

Alt Text


console.log(`I LOVE 💜 %c${name}`, "color: red; font-size: 50px");

will produce

Alt Text


console.log(`%cI LOVE 💜 %c${name}`, "color: red; font-size: 50px");

will produce

Alt Text

If you liked this, please let me know in the comment.

Thanks,
CapsCode