DEV Community

Cover image for How to Copy a Big Object or Array From Console to Clipboard

How to Copy a Big Object or Array From Console to Clipboard

Vitor Paladini
A software engineer that really likes working with user interfaces. Writes mostly JS at Loves cooking.
Originally published at ・Updated on ・1 min read

Have you ever found yourself trying to Ctrl-C a console.log() output, only to get mad when it doesn't really work with long Objects and Arrays?

Gif showing a failed attempt to copy a big object

Here's what you should do instead:

1 - Right-click the console.log() output
2 - Click "Store as global variable"
3 - Run copy(temp1)
4 - Ctrl-V it wherever you want

Gif showing how to copy a long object

Success! You may find that useful when debugging complex data structures or request payloads.

Let me know in the comments what else copy() might be useful for! πŸ˜„

Cover photo by Paolo Nicolello on Unsplash

Why the cover photo is a monkey? Well, I make the same face when I'm debugging.

Hey, let's connect πŸ‘‹

Follow me on Twitter and let me know you liked this article!

And if you really liked it, make sure to share it with your friends, that'll help me a lot πŸ˜„

Discussion (15)

lionelrowe profile image

Awesome tip, I never knew about copy before! In your example, you don't need to Store as global variable though β€” you could just copy(bigObject) directly.

vtrpldn profile image
Vitor Paladini Author • Edited

You're right! I've created bigObject so I could simulate something like:

  .then(response => response.json())
  .then(data => console.log(data.bigObject));

but I'm glad you caught that πŸ˜„

cloudpower97 profile image
Claudio Cortese

Nice tip, never heard of copy before!

bravemaster619 profile image

Good tip! My hack was this:

Enter fullscreen mode Exit fullscreen mode

with Command C, V.

Very uncomfortable compared to copy method

____marcell profile image
Marcell Cruz

Great tip, but I think the gifs are a little bit too fast

vtrpldn profile image
Vitor Paladini Author

Thanks for feedback, Marcell. I thought that would be the case...

I speed them up to decrease the overall frame count making each gif lighter, but I agree that it is looking a little intense 😬

I'll fix them and update the post, thanks!

jonrandy profile image
Jon Randy • Edited

Or just use Firefox, right click and 'Copy object'. Firefox's dev tools really are better than Chrome's IMO

madza profile image

A neat little trick that could come in handy at times πŸ”₯πŸ‘

vtrpldn profile image
Vitor Paladini Author

I'm stealing "neat little trick" for the name of this series, thanks πŸ˜„

madza profile image

I feel a lot of πŸ”₯πŸ”₯πŸ”₯ coming in the future! πŸ’―

amegabosco profile image

Amazing ! Can you please share the tool used to generate the gif capture ?

vtrpldn profile image
Vitor Paladini Author

Of course! I've used Kap for capturing it and Gif Brewery for optimizing it and making it faster πŸ˜„

abdisalan_js profile image

Very useful! Thanks πŸ‘πŸΎ

vtrpldn profile image
Vitor Paladini Author

Glad I could help!

rammohan222 profile image

Definitely It will reduce my frustration while I'm debugging the code πŸ‘Œ

Forem Open with the Forem app