Over a million developers have joined DZone.

How to Use Chrome Developer Tools JavaScript Source Snippets

With Chrome Code Snippets we can ‘run’ small chunks of code without using the console. And using a gist, we can import and export them to a file.

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

We already know that we can run custom JavaScript code from the console. I explained that in this blog post.

And we can use Google Chrome Code snippets to reuse that code over time.

By default, we can’t import and export, but people have written helpful code to let us do that as well.

Google Chrome Snippets

The Google Chrome Snippets tool allows you to store short ‘snippets’ of JavaScript code in the dev tools, rather than having to copy and paste into the console all the time.


If you right click on a snippet you can ‘run’ it.

Remember to hit  ctrl+s to save it, you’ll know if it is saved because it will no longer have the ‘*’ next to it.

Collections of Snippets

You can find collections of other people’s snippets online.

Can We Import and Export Snippets?

If you Ctrl + Shift + I and open a ‘secondary’ Dev tools for the Dev Tools, then this gives you access to the snippets API.

E.g. stackoverflow.com/questions/34936456

InspectorFrontendHost.getPreferences(function(prefs) {

We can import and export snippets using this gist:


Copy and paste theraw gist into your ‘secondary’ dev tools. After you import, remember to ‘save to chrome’.


If you find yourself working from the console, then this is a really useful way to manage your code snippets. And having the ability to import and export allows you to keep your snippets clean and only have the snippets for the application you are testing.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

javascript,chrome dev tools

Published at DZone with permission of Alan Richardson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}