DEV Community

Hunter Chang
Hunter Chang

Posted on

Easily Copy Objects and Arrays from Chrome's Console

When we console.log() some data that's in the form of an object or an array, it's hard to copy and paste the results from Chrome's console. If you try and highlight what's there, you'll just end up with something like Array(3) when you paste, instead of the actual data.

I just learned this easy method of copying things out of Chrome's console.

When you see the data in the console, right click on it to store as global variable.

Chrome will store it as a temporary variable called temp1

Once you have your variable, just use the copy() function.

copy(temp1)
Enter fullscreen mode Exit fullscreen mode

Hit enter and you'll see undefined right below it, which is normal.

Now you'll have all the data in your clipboard, just paste it anywhere you like!

[
  {
    "data": "data for res #1"
  },
  {
    "data": "data for res #2"
  },
  {
    "data": "data for res #3"
  }
]
Enter fullscreen mode Exit fullscreen mode

Top comments (5)

Collapse
 
itzk7 profile image
Kesavan Palani

It won't work always. For complex array of objects it will return as [object Object],[object Object],[object Object],[object Object].

Collapse
 
sakthivelar profile image
sakthivel-ar

copy(temp1.toArray())

Collapse
 
samrocksc profile image
Sam Clark • Edited

You can just create a quick map of the complex object and it will spit them out :O)

Collapse
 
atesdanis profile image
Ateş DANIŞ

so how can we copy it.. is there anybody knows?

Collapse
 
mikolaj_kubera profile image
Mikolaj Kubera

Thanks for the post. There's now an option to "Copy object" in Chromium's dev tools. 👌