How do I create formatted javascript console log messages

Yes, you can format the console.log() with something like this:

console.log("%cExtra Large Yellow Text with Red Background", "background: red; color: yellow; font-size: x-large");

Note the %c preceding the text in the first argument and the style specifications in the second argument. The text will look like your example.

See Google’s “Styling Console Output with CSS” or FireBug’s Console Documentation for more details.

The documentation links also include some other neat tricks like including object links in a console log as well.

Leave a Comment