45+ Excellent Code Snippet Resources and Repositories

Advertisement

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 Overflow6
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.

Screenshot7

Snipplr8
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.

Screenshot9

Smipple10
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.

Screenshot11

Tipster12
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.

Screenshot13

Snipt14
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.

Screenshot15

DZone Snippets16
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.

Screenshot17

Koders18
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.

Screenshot19

Joyent CodeSnippets20
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.

Screenshot21

byteMyCode22
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.

Screenshot23

Refactor My Code24
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.

Screenshot25

Krugle26
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.

Screenshot27

Naslu28
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.

Screenshot29

CodeCodex30
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.

Screenshot31

Snippets32
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.

Screenshot33

Github34
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.

Screenshot35

Codase36
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.

Screenshot37

Google Code Search38
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.

Screenshot39

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

Screenshot41

Code:Keep42
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).

Screenshot43

Snippetsmania44
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.

Screenshot45

DevSnippets46
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.

Screenshot47

Server Fault48
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.

Screenshot49

Refactory.org50
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”).

Screenshot51

Code Sucks Code Snippets52
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.

Screenshot53

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 Snippets54
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.

Screenshot55

Snyppets56
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.

Screenshot57

PHP Snippets58
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.

Screenshot59

Konstruktors60
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.

Screenshot61

GotCodeSnippets.NET62
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.

Screenshot63

GreaseSpot Code Snippets64
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.

Screenshot65

Code Beach66
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.

Screenshot67

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

Screenshot69

10 Code Snippets for PHP Developers70
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.

Screenshot71

PHP Classes72
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.

Screenshot73

The Code Project74
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#.

Screenshot75

SWT Snippets76
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.

Screenshot77

Ruby Snippets78
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.

Screenshot79

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

Screenshot83

DotNetSlackers84
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.

Screenshot85

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{86
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.

Screenshot87

Snipt88
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.

Screenshot89

cnprog90
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.

Screenshot91

↑ Back to topShare on Twitter

Cameron Chapman is a professional Web and graphic designer with over 6 years of experience. She writes for a number of blogs, including her own, Cameron Chapman On Writing. She’s also the author of The Smashing Idea Book: From Inspiration to Application.

  1. 1

    this 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

    0
  2. 2

    Another very useful article. Thanx a lot, Cameron.
    BTW, the link for internetfamous.com does not work.

    0
  3. 3

    Just what I was looking for. Thanks, SM!

    0
  4. 4

    brilliant

    0
  5. 5

    Great post. As usual… Thanks.

    0
  6. 6

    woh – what a list.

    For ZendFramework Snippets look at http://www.zfsnippets.com.

    0
  7. 7

    Great post
    Thanks :)

    0
  8. 8

    Anyone use any of these? if so.. recommendations?

    0
  9. 9
  10. 10

    PHPclasses 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

    0
  11. 11

    Nice list, thanks.

    Also for using SilverStripe CMS there is http://www.SSbits.com

    0
  12. 12

    Grrreat…

    Although a bit of information overload!

    0
  13. 13
  14. 14

    worth to bookmarked. thanks for sharing..;)

    0
  15. 15

    George Litchfield

    July 21, 2009 3:42 am

    Great resource.

    0
  16. 16

    A Website Designer

    July 21, 2009 4:09 am

    No doubt each web developer will have their favourite amongst this vast list of code storage options.

    0
  17. 17

    Grat list.
    What about offline snippet libararies? Any recomendations?

    0
  18. 18

    GREAT GREAT post. I usually just kept the codes in Notepad, but I’m going to use Snipplr now.

    0
  19. 19

    Ah, man, you’re missing JS Bin – live development sandbox and collaborative debugging environment (you can test/debug Ajax too!)

    0
  20. 20

    adding Wordtaps web development and web design sharing powered by wordpress

    0
  21. 21

    these 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.

    1
  22. 22

    There’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.

    0
  23. 23

    Sweet 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.

    0
  24. 24

    great article!

    0
  25. 25

    Miguel Hernandez

    July 21, 2009 12:20 pm

    Thanks 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.

    0
  26. 26

    Miguel Hernandez

    July 21, 2009 12:21 pm

    Ok, nm, must have been a hiccup. That url is working now. :)

    0
  27. 27

    Jeez – 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 :)

    0
  28. 28

    i love stack overlow a lot..thanks for this wonderful post.. :)
    good work smashing

    0
  29. 29

    Thanks smashing. It’s wonderful post. its amazing website ever seen. really beautiful.. smash rocks!!

    0
  30. 30

    Us developers DO like our code snippets don’t we

    – Lee

    0
  31. 31

    THIS IS ROCKN’ROLL!

    0
  32. 32

    Pretty neat !!
    I’ve used some of these in the past but great to find new ones>>

    0
  33. 33

    Another small, but evolving one:

    0
  34. 34

    Excellent listing. Would like to recommend DynamicDrive.com as a source of stuff useful to webbies.
    Cheers!

    0
  35. 35

    I 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

    0
  36. 36

    Interesting list, but missing some heavy hitters. PlanetSourceCode has been around for a LONG time, and still has a lot to offer.

    0
  37. 37

    some 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

    0
  38. 38
  39. 39

    “She’s also the author of the forthcoming book, Internet Famous” link is broken. Try internetfamousbook instead.

    0
  40. 40

    Nice list!

    You forgot DynamicDrive.com?

    0
  41. 41

    i like http://textsnip.com for twitter sharing

    0
  42. 42

    I 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.

    0
  43. 43

    David San Filippo

    February 19, 2010 7:49 pm

    Can’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/.

    0
  44. 44

    thank you good sharing

    bilgi yarışması

    0
  45. 45

    I don’t see our product, Code Barrel, in your list. Try it out at http://www.codebarrel.com. It’s free.

    0
  46. 46

    Awesome list… But might have added http://hscripts.com to too.. an wonderful webmaster resource

    0
  47. 47

    Alexander Rivas

    April 16, 2011 5:36 pm

    great list thanks for posting

    0
  48. 48

    I 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);

    0
  49. 49

    Oh 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.

    0
  50. 50

    Rosie Phillips

    May 7, 2011 4:47 am

    Another 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.

    0
  51. 51

    Awesome post!! :)
    thanks cameron..

    0
  52. 52
  53. 53

    Interesting list, but you missed:
    http://www.codesphp.com

    0
  54. 54

    I 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 :)

    0
  55. 55

    Hey, 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!

    0
  56. 56

    That is a wonderful list of codes and snippets. You can also added HScripts.com. There are various codes and snippets under all languages.

    0
  57. 57

    sebastianpiperry

    March 20, 2012 7:26 pm

    Hmm 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.

    0
  58. 58

    You can also try http://www.ireusable.com for storing you code snippets and searching other users code.

    0
  59. 59

    Try http://www.phpscribble.com for interactive php code snippets and examples.

    0
  60. 60

    Awesome collection. Just what i was googling for. Thanks champman.

    0
  61. 61

    Google Shut down CodeSearch :(

    0
  62. 62

    http://www.snip2code.com is another excellent snippet repository.

    1
    • 63

      Thanks I agree.
      snip2code does really fit my needs for searching only for useful code examples.

      1
      • 64

        Yeah, snip2code seems the killer app in this field. It has just the feature I need, most of all the capability to share snippets with other guys keeping them “protected” from other people: I use this feature to share my guidelines with my team

        0
    • 66

      I tried snip2code, great service! Obviously it could be improved…

      0
  63. 67

    Another one to consider is searchcode [dot] com which does searches over code repositories from GitHub, BitBucket, Sourceforge and others.

    0
  64. 68

    I recommend you CodeSnippets.pl http://www.codesnippets.pl
    -add new snippets
    -advance search
    -code categorize
    -comments
    -highlight code

    0
  65. 69

    Great work!!!!!
    This will surely reduce significant amount of rework for small problems.

    0
  66. 70

    Awesome list!

    I personally use http://www.fablecode.com for .NET code snippets.

    0
  67. 71

    Cool, bit old!

    I personally use http://www.snippetrepo.com for all my code snippets.

    0

↑ Back to top