Using Chrome Developer Tools, i have printed a JSON object with console.log.
is there a way that I can copy it to the clipboard?
Using Chrome Developer Tools, i have printed a JSON object with console.log.
is there a way that I can copy it to the clipboard?
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
Another simple method...from the console surround the json with JSON.stringify(yourobjecthere). Then highlight the text or optionally select the Copy button in the developer bar if it exceeds X number of rows. Hope this helps someone.
Example:
JSON.stringify(JSON.parse(window.atob(localStorage.getItem('C_C_M'))))
The answer given by @Bertrand works. But it won't when there is already an element by the name of copy in the Dom.
Doing copy(temp1) gave me Uncaught TypeError: copy is not a function
So, I removed that element from the Dom in my console using the below line:
document.querySelector('#copy').remove()
Now copy(temp1) works!
Select the text in the console, then use right click -> copy
To copy the entire log (when I needed): hit ctrl-a (select all) then ctrl-c (copy)
Note: Since posting this I noticed sometimes it is necessary to select a little text before these steps work. Also for a long console output scroll to the top of the console and select a little text first. Grrr... still this is easier than saving as a file.
== Above is using Chrome 35 ==