About The Author

Cameron Chapman is a professional Web and graphic designer with over 6 years of experience. She writes for a number of blogs and is the author of The Smashing … More about Cameron

45+ Excellent Code Snippet Resources and Repositories

Quick Summary

The beauty of code snippets is their ability to save you time when developing a site. Whether you keep a file with your own often-reused snippets or turn to one of the many online repositories, snippets can really speed up your site development. There are plenty of places online to find code snippets and get answers to your coding questions. And many of these places let you upload your own snippets, either for personal use or to share with the community. They can also be a great place to find inspiration if you’re trying to figure out the best approach for any aspect of your site’s development. Be sure to check out some of our previous articles: * 40+ Tooltips Scripts with AJAX, JavaScript and CSS * 45+ New jQuery Techniques For Good User Experience * 10 Advanced PHP Tips Revisited * 70 New, Useful AJAX And JavaScript Techniques * 70 Expert Ideas For Better CSS Coding

Table of Contents
Membership counter

Members support Smashing

Wonderful, friendly people who keep this lil' site alive — and get smarter every day.

Are you smashing, too? →

The beauty of code snippets is their ability to save you time when developing a site. Whether you keep a file with your own often-reused snippets or turn to one of the many online repositories, snippets can really speed up your site development.

There are plenty of places online to find code snippets and get answers to your coding questions. And many of these places let you upload your own snippets, either for personal use or to share with the community. They can also be a great place to find inspiration if you’re trying to figure out the best approach for any aspect of your site’s development.

Be sure to check out some of our previous articles:

1. General Snippet Repositories and Resources

The repositories and resources featured below cover multiple languages and platforms. Some have thousands of code snippets while others might only have a couple hundred. Most of them let you search by language, tag, author, or keyword. And most of them let you upload your own snippets or questions.

Stack Overflow
Stack Overlow is a great site to check out if you have a programming question. Post your question and wait for answers. You and other users can then vote on the answers posted. You can also search questions based on keywords or tags, view unanswered questions, and sort by newest, oldest, featured, and other criteria.

Screenshot

Snipplr
Snipplr is a code snippet search engine. It's a way for you to keep your code snippets organized and easily accessible from any computer. It includes snippets in JavaScript, HTML, PHP, CSS, Ruby and Objective C.

Screenshot

Smipple
Smipple is a repository of "social code snippets". You can browse by popular or recent snippets, save favorites, and submit your own snippets. You can also search based on keywords or tags.

Screenshot

Tipster
Tipster, from Carsonified (the producers of the Future of Web Design conference), is a place to share and find tips from other web designers. In addition to searching tips, you can also view hot tips and vote tips up the charts.

Screenshot

Snipt
Snipt is a code repository that allows you to save public or private snippets. There are snippets available in just about every programming language and web technology you could ask for. Some of the snippets are incredibly useful, such as prebuilt HTML test pages for creating your CSS.

Screenshot

DZone Snippets
DZone Snippets is a public code repository that lets you tag your code and share them with others. They have tons of different categories, covering everything from JavaScript to Python to HTML to XML and just about everything in between.

Screenshot

Koders
Koders is a code repository with nearly 2.5 billion lines of open source code. The search engine they use is very powerful and allows you search based on a variety of different criteria, including by class, method, interface, and more.

Screenshot

Joyent CodeSnippets
Here's another public source code repository that lets you share your code or keep it private. Currently, there are more than 4,000 users sharing snippets. One of the nicer features of this particular repository is the ability to subscribe to an RSS feed of all snippets or just those tagged with particular keywords.

Screenshot

byteMyCode
ByteMyCode splits up their snippets based on programming language. There are tags for CSS, HTML, MySQL, Java, PHP, and just about anything else you could think of. You can browse by tag, new snippets or top snippets, or search by keyword.

Screenshot

Refactor My Code
This is a great resource if you want to get others to check your code for errors or inefficiencies. Just post some code, let other members know what you need help with, and wait for responses. You can also browse through "refactorings" and codes based on language.

Screenshot

Krugle
Krugle is a powerful code search engine that lets you search either code, projects, or comments. Filters are available to refine searches based on language or where the term appears.

Screenshot

Naslu
Naslu lets you search code in any language and from authors all over the world. One big advantage they offer is the ability to link code snippets into external web pages.

Screenshot

CodeCodex
CodeCodex is a wiki-based code repository that lets members not only share code, but also improve code shared by others. It also lets users reorganize the library to make it more efficient and easier to find specific bits of code.

Screenshot

Snippets
This snippet repository is hosted by Jonas John. It contains over 160 code snippets, primarily in PHP, though there are some in C#, Visual Basic, JavaScript and plain HTML.

Screenshot

Github
Github offers a number of forked repositories in a huge variety of languages. You can browse repositories based on what's popular, or search based on keyword, size, the number of forks, and more. Popular repositories include Rails, Scriptaculous, and MaNGOS.

Screenshot

Codase
Codase is a syntax-aware code search engine that understands code and, therefore, performs more accurate searches. There are currently more than 250 million lines of code in its repository.

Screenshot

Google Code Search
This code search engine from Google lets you search public source code from across the web. The advanced search lets you search within languages, licenses, packages, files, and more.

Screenshot

Snipiti
Snipiti is a code repository and community. It focuses on cut & paste snippets in a variety of different languages, including PHP, HTML and Python.

Screenshot

Code:Keep
Code:Keep is a repository of nearly 15,000 snippets in just about every language out there. You can browse or search, or even look up code based on an author's email address (great for finding your own contributed code).

Screenshot

Snippetsmania
Snippetsmania is a small code repository that includes snippets written in C, Cobol, JavaScript, PHP, Perl and others. It provides a list of the most popular snippets and organizes other snippets based on language and date. There's also a search option.

Screenshot

DevSnippets
DevSnippets is an online snippet gallery that provides snippets as well as useful development articles for a variety of platforms and languages. Snippets are located off-site, generally on the blogs of their respective creators.

Screenshot

Server Fault
Server Fault is a question and answer site aimed at IT pros and system administrators. It's completely free and there's no registration required. Just post a question and wait for answers. You can see how many times your question has been viewed, how many answers have been offered, and how many votes the question has received.

Screenshot

Refactory.org
Refactory is a community-maintained collection of snippets available for public use. There's no registration required to contribute. You can view snippets based on language or other tags (like "image" or "forms" or "anchor").

Screenshot

Code Sucks Code Snippets
Code Sucks offers a collection of CSS, JavaScript and PHP code snippets. There aren't a huge number of snippets included, but those listed are useful and easy to understand.

Screenshot

2. Language- and Platform-Specific Repositories

The code repositories below are all dedicated to a single language or platform. These are excellent resources if you’re stuck on a certain function and the general repositories have failed you. They’re also a great place to keep your code snippets or share them with others who are more like-minded than general repository users. While most of the repositories here are small, with only a few dozen to a couple hundred snippets, there are some that offer more.

Django Snippets
This repository contains snippets of code specific to the Django web framework. You can view snippets based on rating, tag, author, language, or how many times they've been bookmarked. You can also subscribe to a feed of the latest snippets.

Screenshot

Snyppets
Snyppets is a repository of Python code, mini-guides, recipes, links, tutorials, examples and ideas. They include basic code right up through advanced topics. The entire site is built on a single HTML page to make saving for offline reference easy.

Screenshot

PHP Snippets
PHP Snippets is a repository of PHP code that you can browse by letter or based on function or class. You can also browse new and highly rated snippets.

Screenshot

Konstruktors
This is a CSS repository that focuses on snippets for building grid and columb-based layouts. It doesn't contain a huge number of snippets, but those it does include are very useful, and it's easier to find what you're looking for.

Screenshot

GotCodeSnippets.NET
This site offers a huge repository of Visual Basic code snippets. You search by language (C#, Visual Basic, XML, or J#). It's not a huge repository, with a little over 100 snippets, but it's still a valuable resource for Visual Basic programmers, and it does let you add your own snippets to the site.

Screenshot

GreaseSpot Code Snippets
This is a wiki-based site that serves as a repository for GreaseMonkey scripts. It includes a ton of useful scripts for everything from getting elements based on CSS selector to adding commas to numbers to forcing links to open in new windows and a lot more.

Screenshot

Code Beach
Code Beach is a repository for Mac developers. You can find code available under a variety of open source licenses (though everything on the site has to be available for commercial use). They also have an open submission policy, so anyone can contribute snippets and classes without having to register.

Screenshot

Snippi
Snippi is a repository for Magento code. Currently there are more than 60 snippets included, from a number of different contributors.

Screenshot

10 Code Snippets for PHP Developers
This is a blog post covering ten useful code snippets. It includes an email address check, random password generator, get IP address, XSL transformation, force downloading of a file, string encoding to prevent harmful code, sending mail, uploading of files, list files in directory, and querying RDBMS with MDB2.

Screenshot

PHP Classes
This is a PHP code repository that lets you search PHP Class Scripts, tutorials, and more. There are a huge number of scripts and snippets covering almost any aspect of PHP coding included. The site is mirrored all over the world and does require that you select a mirror before browsing.

Screenshot

The Code Project
The Code Project has nearly 24,000 development and design articles, code snippets, and other resources available. It focuses on Microsoft-based and related languages like ASP.NET and C#.

Screenshot

SWT Snippets
This is a huge repository of snippets for SWT (The Standard Widget Toolkit). Code includes snippets related to accessibility, browser functions, cursors, display, grid layouts, and more.

Screenshot

Ruby Snippets
This is a small collection of Ruby and Ruby on Rails snippets from Arto Bendiken. There are snippets included for generating random passwords, simple RSS parsing, and determining image size, among others.

Screenshot

RubyForge Snippets
Another collection of 176 Ruby and Ruby on Rails snippets and packages. Also take a look at the post 8 More Useful Ruby Code Snippets and A Selection of Ruby Code Snippets.

Screenshot

DotNetSlackers
DotNetSlackers is community and forum dedicated to ASP.NET. They also have a code repository that includes a wide variety of snippets in MS-based coding languages.

Screenshot

3. Other Code Snippet Resources

Here are a few other resources for finding code if the repositories above have failed you, for sharing your code outside of a repository, or even creating your own snippet or Q & A site.

CodeFetch{
Codefetch lets you search code snippets within programming books and makes it easy for you to then order the books that fit your needs. It covers a variety of different languages, including PHP, Java, Python, and Perl.

Screenshot

Snipt
Snipt lets you store and then share your code snippets on Twitter and elsewhere. You can also search the Snipt repository or download the Snipt desktop app.

Screenshot

cnprog
Cnprog is based on StackOverflow.com. It was developed on Django and Python and allows developers to set up their own snippet repositories and coding Q&A sites.

Screenshot