45+ Excellent Code Snippet Resources and Repositories
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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”).
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.
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.
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.
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.
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.
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.
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.
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.
Snippi
Snippi is a repository for Magento code. Currently there are more than 60 snippets included, from a number of different contributors.
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.
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.
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#.
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.
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.
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.
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.
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.
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.
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.














































Tom
July 21st, 2009 12:28 amthis is a very good roundup and worth a digg. my plan was to research in my delicious for those ressources and you made my job. great work, bookmarked
Gerd Wippich
July 21st, 2009 12:38 amAnother very useful article. Thanx a lot, Cameron.
BTW, the link for internetfamous.com does not work.
JaycobC
July 21st, 2009 12:49 amJust what I was looking for. Thanks, SM!
Sven Lito
July 21st, 2009 1:09 ambrilliant
liberta
July 21st, 2009 1:23 amGreat post. As usual… Thanks.
rainer
July 21st, 2009 2:07 amwoh – what a list.
For ZendFramework Snippets look at http://www.zfsnippets.com.
Hastimal Shah
July 21st, 2009 2:25 amGreat post
Thanks :)
ilz
July 21st, 2009 2:41 amAnyone use any of these? if so.. recommendations?
Mark Wisecarver
July 21st, 2009 2:49 amhttp://www.codeplex.com/
liberta
July 21st, 2009 2:53 amPHPclasses is very old and well know by developpers, just be suspicious on code.
I know PHPclasses and Snipplr, they are ok. As usual, you must see and build your own opinion reading code but it’s ok
Aram
July 21st, 2009 3:10 amNice list, thanks.
Also for using SilverStripe CMS there is http://www.SSbits.com
Tschai
July 21st, 2009 3:16 amGrrreat…
Although a bit of information overload!
spirit
July 21st, 2009 3:25 amYou also have http://www.posteet.com
not2comply
July 21st, 2009 3:36 amworth to bookmarked. thanks for sharing..;)
George Litchfield
July 21st, 2009 3:42 amGreat resource.
A Website Designer
July 21st, 2009 4:09 amNo doubt each web developer will have their favourite amongst this vast list of code storage options.
Adi
July 21st, 2009 4:55 amGrat list.
What about offline snippet libararies? Any recomendations?
Jessi
July 21st, 2009 5:30 amGREAT GREAT post. I usually just kept the codes in Notepad, but I’m going to use Snipplr now.
Remy Sharp
July 21st, 2009 7:37 amAh, man, you’re missing JS Bin – live development sandbox and collaborative debugging environment (you can test/debug Ajax too!)
mupet
July 21st, 2009 7:43 amadding Wordtaps web development and web design sharing powered by wordpress
damonm
July 21st, 2009 7:55 amthese lists are great, but my big problem with them is always how they’re presented with the comments… the descriptions are usually very brief and often just blanket praise, which I’m sure is what the respective site owners want to hear, but what I want to hear is critical info… how good quality is the code? is it up to date? how much do they have? are they frequently updated? which of those sites has the most in general? how do they compare to one another? that would make this and other similar posts truly useful. Otherwise it’s basically just a fancy looking google search and I’m still not sure which of the sites are worthy my time. It’s a general trend on all these lists, and it is what’s currently holding this site back from being truly smashing.
Manon
July 21st, 2009 8:52 amThere’s also a desktop solution for collecting snippets that I’m really interested in, and think about purchasing even though I do have TextMate: Code Collector Pro.
Jake
July 21st, 2009 10:10 amSweet collection! When first starting to learn PHP or JavaScript I lived off of smaller code snippets to learn how professionals did it, so articles like these are best for beginners trying to learn new languages.
danny
July 21st, 2009 10:21 amgreat article!
Miguel Hernandez
July 21st, 2009 12:20 pmThanks for this exhaustive list. While I knew about & used some of these, there were many that I did not know about. Very useful.
Btw, the http://phpclasses.org link is not working.
Miguel Hernandez
July 21st, 2009 12:21 pmOk, nm, must have been a hiccup. That url is working now. :)
Shane
July 21st, 2009 12:35 pmJeez – information overload – I find it hard to imagine how anybody can digest all the information presented in these posts. That’s not a criticism, more of an observation; quite amazing stuff.
It sometimes makes me think that being a web developer these days is more about knowing where to find information than using a brain :)
gaurav
July 21st, 2009 9:24 pmi love stack overlow a lot..thanks for this wonderful post.. :)
good work smashing
Ankit
July 21st, 2009 10:20 pmThanks smashing. It’s wonderful post. its amazing website ever seen. really beautiful.. smash rocks!!
Englestone
July 21st, 2009 11:27 pmUs developers DO like our code snippets don’t we
– Lee
Hezi
July 22nd, 2009 12:46 amTHIS IS ROCKN’ROLL!
sanjeev
July 22nd, 2009 5:21 amPretty neat !!
I’ve used some of these in the past but great to find new ones>>
Trekstuff
July 22nd, 2009 11:00 amAnother small, but evolving one:
Spud Lite
July 22nd, 2009 11:41 amExcellent listing. Would like to recommend DynamicDrive.com as a source of stuff useful to webbies.
Cheers!
seph
July 22nd, 2009 11:50 amI may be bias but I can certainly recommend Bitbucket, http://www.bitbucket.org as an alternative. There’s code hosting for free and search for other open-source projects as well. A lot of Django and python-based projects are found here.
Regards
Tore
July 22nd, 2009 12:54 pmInteresting list, but missing some heavy hitters. PlanetSourceCode has been around for a LONG time, and still has a lot to offer.
Ronald H.
July 22nd, 2009 7:39 pmsome of them suck but I like most of them. great stuff buddy. if you could, please do more on jquery, using php in wordpress, and creating wp templates. thanks
Dav0id
July 22nd, 2009 9:56 pmInteresting list, but you missed:
http://www.programmersheaven.com/
and
http://www.thefreecountry.com/
Lewis
July 23rd, 2009 4:50 am“She’s also the author of the forthcoming book, Internet Famous” link is broken. Try internetfamousbook instead.
Archit
July 26th, 2009 7:35 amNice list!
You forgot DynamicDrive.com?
jane
July 27th, 2009 6:11 ami like http://textsnip.com for twitter sharing
Danny Vogler
October 2nd, 2009 2:02 pmI just created http://www.snippetgood.com
This is a beta stackexchange website. Wish me luck!
When a problem comes around, you must Snippet. Snippet good.
David San Filippo
February 19th, 2010 7:49 pmCan’t resist the shameless plug: For a drag and drop Snippet Toolbar for windows with search, code templates and clipboard history that also integrates with Snipplr, check out my product: Snip-It Pro: http://www.snipitpro.com/.
Glow
June 22nd, 2010 3:30 pmthank you good sharing
bilgi yarışması
Keir
August 4th, 2010 5:00 amI don’t see our product, Code Barrel, in your list. Try it out at http://www.codebarrel.com. It’s free.
geetha
December 17th, 2010 5:03 amAwesome list… But might have added http://hscripts.com to too.. an wonderful webmaster resource
Alexander Rivas
April 16th, 2011 5:36 pmgreat list thanks for posting
Dave
April 20th, 2011 12:38 amI am new to advanced C++ code, so I need some help on understanding a few things.
Code snippet 1: (Why the []??)
delete [] m_pParm;
Code snippet 2: (What is the _DEXPORT?? I assume this is a function that returns a double, but could _DEXPORT be some kind of object that gets returned instead of a double??)
double _DEXPORT Circ(int np, double **pdAc, double **pdV, double *X0,
double &R, e_approx approx=lsq);
Steve
April 28th, 2011 4:48 amOh my goodness! THIS is what I need too! Ahhh! 45 steps and my business is on track. I have lots of small scale business which I want to develop and take on high heights but due to proper links and contacts, now in storage… but it needs a lot of attention… I am thinking if you could just provide me a better luck for the purpose! I am looking in this area by creating an attractive and fascinating webpage for my business so that I get easy finance to start my business. The process stated seems to be lengthy but I know you will definitely help me to sort out my problem.
Rosie Phillips
May 7th, 2011 4:47 amAnother very useful article. Thanx a lot, Cameron. I usually just kept the codes in MS word, but I’m going to use this now. I knew about & used some of these, there were many that I did not know about. Very useful and exclusive list.
@sit
May 14th, 2011 12:02 pmAwesome post!! :)
thanks cameron..
Tommy
May 23rd, 2011 1:08 amUpdate more :
http://icodesnippet.com and http://icodesnip.com are also good.
Arbaoui Mehdi
May 29th, 2011 5:03 amInteresting list, but you missed:
http://www.codesphp.com
ersatzteile
August 8th, 2011 3:40 amI like what you guys are up too. Such smart work and reporting! Carry on the superb works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website :)
Aussie Punter
September 25th, 2011 10:47 pmHey, thanks for these links. Just what I was looking for as I’m still learning to program and I find the best way for me to learn is to look at others’ code. I’ve got a bunch more bookmarks now, including this one!
Ananya
March 14th, 2012 1:08 pmThat is a wonderful list of codes and snippets. You can also added HScripts.com. There are various codes and snippets under all languages.
sebastianpiperry
March 20th, 2012 7:26 pmHmm it seems like your site ate my first comment (it was super long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog. I too am an aspiring blog blogger but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d genuinely appreciate it.
mobi
June 13th, 2012 1:47 amYou can also try http://www.ireusable.com for storing you code snippets and searching other users code.
Silver Moon
July 12th, 2012 7:37 amTry http://www.phpscribble.com for interactive php code snippets and examples.
Collizo4sky
January 20th, 2013 2:46 pmAwesome collection. Just what i was googling for. Thanks champman.
DrWhat
March 15th, 2013 12:31 amGoogle Shut down CodeSearch :(
Fabio
June 6th, 2013 2:14 pmhttp://www.snip2code.com is another excellent snippet repository.
Shan Wen Li
June 13th, 2013 10:05 amThanks I agree.
snip2code does really fit my needs for searching only for useful code examples.