Copy to Clipboard in Google Chrome Console

When developing for the web, sometimes I want to JSONify an object to throw into Sublime Text for an easier look or maybe to compare two separate objects.

While it’s easy to log an object in Google Chrome, the issue I have is easily getting that from the console to Sublime Text.

After doing a bit of searching, I found that Google Chrome has a copy function that will copy any text to the clipboard.

Here are a couple of ways that you could use this function:

To copy any string, simply use

copy( "some string here" );

To copy a JSONified object, you could use something like:

copy( JSON.stringify( object ) );

Leave a Reply

Your email address will not be published. Required fields are marked *