Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pretty print log output in Chrome DevTools Console?

I'm hoping to be able to pretty print array objects and such in the Console of Chrome DevTools. Is there any means to achieve this?

Thank you!

like image 484
Villi Magg Avatar asked Aug 12 '13 10:08

Villi Magg


People also ask

How do I make a pretty print in Chrome console?

If it's the Sources panel, you can manually enable or disable pretty-printing by clicking Format. In general, if you see that icon anywhere, clicking it will enable or disable pretty-printing. Show activity on this post. I just did the same thing because of the really poor UI there.

How do you get pretty print on console?

If you whant to pretty print a block of js code minimized in a long line add somewhere at the beginnig of code a debugger statement, than paste to the console and run thwe code. The Debugger statement will be reached and the code will be opened into "sources" panel. Here you can use the pretty print button.

How do I print an image from console log?

log('%c ', style); }; image. src = url; }; and then just use console. image(URL[, size]); to print out the image.


1 Answers

You could format the data as JSON:

console.log(JSON.stringify({foo:1, bar:2}, null, 4));  {     "foo": 1,     "bar": 2 }  
like image 107
Petah Avatar answered Sep 29 '22 12:09

Petah