Menu Search
Jump to the content X X
Smashing Conf New York

We use ad-blockers as well, you know. We gotta keep those servers running though. Did you know that we publish useful books and run friendly conferences — crafted for pros like yourself? E.g. upcoming SmashingConf Barcelona, dedicated to smart front-end techniques and design patterns.

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:

1. General Snippet Repositories and Resources Link

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

Screenshot6

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

Screenshot8

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

Screenshot10

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

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

Screenshot12

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

Screenshot14

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

Screenshot16

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

Screenshot18

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

Screenshot20

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

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

Screenshot22

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

Screenshot24

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

Screenshot26

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

Screenshot28

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

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

Screenshot30

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

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

Screenshot32

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

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

Screenshot34

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

Screenshot36

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

Screenshot38

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

Screenshot40

2. Language- and Platform-Specific Repositories Link

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

Screenshot42

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

Screenshot44

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

Screenshot46

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

Screenshot48

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

Screenshot50

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

Screenshot52

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

Screenshot54

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

Screenshot56

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

Screenshot58

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 Snippets59
Another collection of 176 Ruby and Ruby on Rails snippets and packages. Also take a look at the post 8 More Useful Ruby Code Snippets60 and A Selection of Ruby Code Snippets61.

Screenshot62

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

Screenshot64

3. Other Code Snippet Resources Link

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

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

Screenshot66

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

Screenshot68

Footnotes Link

  1. 1 https://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/
  2. 2 https://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/
  3. 3 https://www.smashingmagazine.com/2009/03/08/70-new-useful-ajax-and-javascript-techniques/
  4. 4 https://www.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-coding/
  5. 5 http://stackoverflow.com/questions/tagged/css
  6. 6 http://stackoverflow.com/questions/tagged/css
  7. 7 http://snipplr.com/popular/language/css
  8. 8 http://snipplr.com/popular/language/css
  9. 9 http://www.smipple.net/
  10. 10 http://www.smipple.net/
  11. 11 http://snipt.net/public/tag/css
  12. 12 http://snipt.net/public/tag/css
  13. 13 http://snippets.dzone.com/
  14. 14 http://snippets.dzone.com/
  15. 15 http://www.koders.com/
  16. 16 http://www.koders.com/
  17. 17 http://codesnippets.joyent.com/
  18. 18 http://codesnippets.joyent.com/
  19. 19 http://www.bytemycode.com/
  20. 20 http://www.bytemycode.com/
  21. 21 http://www.krugle.org
  22. 22 http://www.krugle.org
  23. 23 http://www.naslu.com/
  24. 24 http://www.naslu.com/
  25. 25 http://codecodex.com/wiki/index.php?title=Main_Page
  26. 26 http://codecodex.com/wiki/index.php?title=Main_Page
  27. 27 http://www.jonasjohn.de/snippets/
  28. 28 http://www.jonasjohn.de/snippets/
  29. 29 http://www.codase.com/
  30. 30 http://www.codase.com/
  31. 31 http://www.snipiti.com/
  32. 32 http://www.snipiti.com/
  33. 33 http://snippetsmania.com/
  34. 34 http://snippetsmania.com/
  35. 35 http://serverfault.com/
  36. 36 http://serverfault.com/
  37. 37 http://www.refactory.org/
  38. 38 http://www.refactory.org/
  39. 39 http://www.code-sucks.com/code/
  40. 40 http://www.code-sucks.com/code/
  41. 41 http://www.djangosnippets.org/
  42. 42 http://www.djangosnippets.org/
  43. 43 http://sebsauvage.net/python/snyppets/
  44. 44 http://sebsauvage.net/python/snyppets/
  45. 45 http://phpsnips.com/
  46. 46 http://phpsnips.com/
  47. 47 http://wiki.greasespot.net/Code_snippets
  48. 48 http://wiki.greasespot.net/Code_snippets
  49. 49 http://codebeach.org/
  50. 50 http://codebeach.org/
  51. 51 http://htmlblog.net/10-code-snippets-for-php-developers/
  52. 52 http://htmlblog.net/10-code-snippets-for-php-developers/
  53. 53 http://www.phpclasses.org/
  54. 54 http://www.phpclasses.org/
  55. 55 http://www.codeproject.com/
  56. 56 http://www.codeproject.com/
  57. 57 http://www.eclipse.org/swt/snippets/
  58. 58 http://www.eclipse.org/swt/snippets/
  59. 59 http://rubyforge.org/snippet/browse.php?by=lang&lang=17
  60. 60 http://www.rubyinside.com/8-more-useful-ruby-code-snippets-171.html
  61. 61 http://erikveenstra.nl/rubycodesnippets/index.html
  62. 62 http://rubyforge.org/snippet/browse.php?by=lang&lang=17
  63. 63 http://dotnetslackers.com/default.aspx
  64. 64 http://dotnetslackers.com/default.aspx
  65. 65 http://snipt.org/
  66. 66 http://snipt.org/
  67. 67 http://github.com/cnprog/CNPROG/tree/master
  68. 68 http://github.com/cnprog/CNPROG/tree/master
SmashingConf New York

Hold on, Tiger! Thank you for reading the article. Did you know that we also publish printed books and run friendly conferences – crafted for pros like you? Like SmashingConf Barcelona, on October 25–26, with smart design patterns and front-end techniques.

↑ Back to top Tweet itShare on Facebook

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

    Grrreat…

    Although a bit of information overload!

    1
  2. 2
  3. 3

    worth to bookmarked. thanks for sharing..;)

    1
  4. 4

    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.

    -1
  5. 5

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

    -1
  6. 6

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

    1
  7. 7

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

    1
  8. 8

    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.

    0
  9. 9

    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.

    1
  10. 10

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

    Gerd Wippich

    July 21, 2009 12:38 am

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

    0
  12. 12

    Just what I was looking for. Thanks, SM!

    0
  13. 13

    brilliant

    0
  14. 14

    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.

    1
  15. 15

    Great post. As usual… Thanks.

    0
  16. 16

    woh – what a list.

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

    0
  17. 17

    Hastimal Shah

    July 21, 2009 2:25 am

    Great post
    Thanks :)

    0
  18. 18

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

    0
  19. 19
  20. 20

    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

↑ Back to top