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

[javascript]
copy( "some string here" );
[/javascript]

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

[code lang=javascript]
copy( JSON.stringify( object ) );
[/code]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.