Menu Search
Jump to the content X X

Today, too many websites are still inaccessible. In our new book Inclusive Design Patterns, we explore how to craft flexible front-end design patterns and make future-proof and accessible interfaces without extra effort. Hardcover, 312 pages. Get the book now →

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

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

Screenshot18

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

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

Screenshot20

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

Screenshot22

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

Screenshot24

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

Screenshot26

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

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

Screenshot28

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

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

Screenshot30

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

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

Screenshot32

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

Screenshot34

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

Screenshot36

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

Screenshot38

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

Screenshot40

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

Screenshot42

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

Screenshot44

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

Screenshot46

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

Screenshot48

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

Screenshot50

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

Screenshot52

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

Screenshot54

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

Screenshot56

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

Screenshot60

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

Screenshot62

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

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

Screenshot64

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

Screenshot66

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://www.bytemycode.com/
  18. 18 http://www.bytemycode.com/
  19. 19 http://www.krugle.org
  20. 20 http://www.krugle.org
  21. 21 http://www.naslu.com/
  22. 22 http://www.naslu.com/
  23. 23 http://codecodex.com/wiki/index.php?title=Main_Page
  24. 24 http://codecodex.com/wiki/index.php?title=Main_Page
  25. 25 http://www.jonasjohn.de/snippets/
  26. 26 http://www.jonasjohn.de/snippets/
  27. 27 http://www.codase.com/
  28. 28 http://www.codase.com/
  29. 29 http://www.snipiti.com/
  30. 30 http://www.snipiti.com/
  31. 31 http://snippetsmania.com/
  32. 32 http://snippetsmania.com/
  33. 33 http://serverfault.com/
  34. 34 http://serverfault.com/
  35. 35 http://www.refactory.org/
  36. 36 http://www.refactory.org/
  37. 37 http://www.code-sucks.com/code/
  38. 38 http://www.code-sucks.com/code/
  39. 39 http://www.djangosnippets.org/
  40. 40 http://www.djangosnippets.org/
  41. 41 http://sebsauvage.net/python/snyppets/
  42. 42 http://sebsauvage.net/python/snyppets/
  43. 43 http://phpsnips.com/
  44. 44 http://phpsnips.com/
  45. 45 http://wiki.greasespot.net/Code_snippets
  46. 46 http://wiki.greasespot.net/Code_snippets
  47. 47 http://codebeach.org/
  48. 48 http://codebeach.org/
  49. 49 http://htmlblog.net/10-code-snippets-for-php-developers/
  50. 50 http://htmlblog.net/10-code-snippets-for-php-developers/
  51. 51 http://www.phpclasses.org/
  52. 52 http://www.phpclasses.org/
  53. 53 http://www.codeproject.com/
  54. 54 http://www.codeproject.com/
  55. 55 http://www.eclipse.org/swt/snippets/
  56. 56 http://www.eclipse.org/swt/snippets/
  57. 57 http://rubyforge.org/snippet/browse.php?by=lang&lang=17
  58. 58 http://www.rubyinside.com/8-more-useful-ruby-code-snippets-171.html
  59. 59 http://erikveenstra.nl/rubycodesnippets/index.html
  60. 60 http://rubyforge.org/snippet/browse.php?by=lang&lang=17
  61. 61 http://dotnetslackers.com/default.aspx
  62. 62 http://dotnetslackers.com/default.aspx
  63. 63 http://snipt.org/
  64. 64 http://snipt.org/
  65. 65 http://github.com/cnprog/CNPROG/tree/master
  66. 66 http://github.com/cnprog/CNPROG/tree/master

↑ Back to top Tweet itShare on Facebook

Advertisement

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?

    0
  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