Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get JSON output in Chrome Dev Tools console?

Tags:

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)

like image 271
Darkmops Avatar asked Jan 05 '15 11:01

Darkmops


People also ask

How do I view JSON response in Chrome developer tools?

In Google Chrome Developer Tools > Resources > XHR when I click on the resource on the left and then on the Content tab I see the JSON string as a string and not as a tree as Firebug and Firebug Lite do.


2 Answers

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.

like image 91
Andrew Boes Avatar answered Sep 22 '22 07:09

Andrew Boes


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.

like image 40
Konrad Dzwinel Avatar answered Sep 21 '22 07:09

Konrad Dzwinel