24

is there a way to output a json in a nice way in the console? I just get "> Object" as the tree root and have to manually navigate through the tree which is annoying.

The best case would be to search for a string within that object. Alternatively expanding everything would be ok as well.

Any ideas?

(Was asked before in Is there a way in Chrome console to search for strings in console outputs, even those collapsed? but not answered)

Flip
  • 6,233
  • 7
  • 46
  • 75
Darkmops
  • 241
  • 1
  • 2
  • 5
  • possible duplicate of [Is there a way to auto expand objects in Chrome Dev Tools?](http://stackoverflow.com/questions/10464844/is-there-a-way-to-auto-expand-objects-in-chrome-dev-tools) – Konrad Dzwinel Jan 05 '15 at 11:25

2 Answers2

57

Got this from Superuser:

If the right-click -> copy is not available you could try:

1 - Right-click the object and select "Store as global variable"

2 - The console will print the new variable's name, for example:

//temp1

3 - Type:

copy(temp1)

The object is now available in your clipboard.

Tested in chrome 36

I used this in Chrome 65 and worked great.

Community
  • 1
  • 1
Andrew Boes
  • 2,013
  • 4
  • 22
  • 29
7

ATM your best option is to use JSON.stringify as explained here.

There is an DevTools Console API for Chrome extensions that allows to customize console output, but it's still experimental.

Konrad Dzwinel
  • 36,825
  • 12
  • 98
  • 105
  • 1
    This works, but the output is funky with quotes everywhere. The first solution works better, IMO, giving you a nicely-formatted object. – JESii Mar 26 '20 at 16:46