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

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.


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


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


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


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


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


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


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


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.


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


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.


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


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.


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


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.


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


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.


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.


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.


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



  1. 1 http://www.smashingmagazine.com/2007/06/12/tooltips-scripts-ajax-javascript-css-dhtml/
  2. 2 http://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/
  3. 3 http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/
  4. 4 http://www.smashingmagazine.com/2009/03/08/70-new-useful-ajax-and-javascript-techniques/
  5. 5 http://www.smashingmagazine.com/2007/05/10/70-expert-ideas-for-better-css-coding/
  6. 6 http://stackoverflow.com/questions/tagged/css
  7. 7 http://stackoverflow.com/questions/tagged/css
  8. 8 http://snipplr.com/popular/language/css
  9. 9 http://snipplr.com/popular/language/css
  10. 10 http://www.smipple.net/
  11. 11 http://www.smipple.net/
  12. 12 http://tipster.carsonified.com/
  13. 13 http://tipster.carsonified.com/
  14. 14 http://snipt.net/public/tag/css
  15. 15 http://snipt.net/public/tag/css
  16. 16 http://snippets.dzone.com/
  17. 17 http://snippets.dzone.com/
  18. 18 http://www.koders.com/
  19. 19 http://www.koders.com/
  20. 20 http://codesnippets.joyent.com/
  21. 21 http://codesnippets.joyent.com/
  22. 22 http://www.bytemycode.com/
  23. 23 http://www.bytemycode.com/
  24. 24 http://refactormycode.com/
  25. 25 http://refactormycode.com/
  26. 26 http://www.krugle.org
  27. 27 http://www.krugle.org
  28. 28 http://www.naslu.com/
  29. 29 http://www.naslu.com/
  30. 30 http://codecodex.com/wiki/index.php?title=Main_Page
  31. 31 http://codecodex.com/wiki/index.php?title=Main_Page
  32. 32 http://www.jonasjohn.de/snippets/
  33. 33 http://www.jonasjohn.de/snippets/
  34. 34 http://github.com/popular/forked
  35. 35 http://github.com/popular/forked
  36. 36 http://www.codase.com/
  37. 37 http://www.codase.com/
  38. 38 http://www.google.com/codesearch
  39. 39 http://www.google.com/codesearch
  40. 40 http://www.snipiti.com/
  41. 41 http://www.snipiti.com/
  42. 42 http://codekeep.net/
  43. 43 http://codekeep.net/
  44. 44 http://snippetsmania.com/
  45. 45 http://snippetsmania.com/
  46. 46 http://devsnippets.com/
  47. 47 http://devsnippets.com/
  48. 48 http://serverfault.com/
  49. 49 http://serverfault.com/
  50. 50 http://www.refactory.org/
  51. 51 http://www.refactory.org/
  52. 52 http://www.code-sucks.com/code/
  53. 53 http://www.code-sucks.com/code/
  54. 54 http://www.djangosnippets.org/
  55. 55 http://www.djangosnippets.org/
  56. 56 http://sebsauvage.net/python/snyppets/
  57. 57 http://sebsauvage.net/python/snyppets/
  58. 58 http://phpsnips.com/
  59. 59 http://phpsnips.com/
  60. 60 http://konstruktors.com/Main/HomePage
  61. 61 http://konstruktors.com/Main/HomePage
  62. 62 http://www.gotcodesnippets.net/default.aspx
  63. 63 http://www.gotcodesnippets.net/default.aspx
  64. 64 http://wiki.greasespot.net/Code_snippets
  65. 65 http://wiki.greasespot.net/Code_snippets
  66. 66 http://codebeach.org/
  67. 67 http://codebeach.org/
  68. 68 http://snippi.net/
  69. 69 http://snippi.net/
  70. 70 http://htmlblog.net/10-code-snippets-for-php-developers/
  71. 71 http://htmlblog.net/10-code-snippets-for-php-developers/
  72. 72 http://www.phpclasses.org/
  73. 73 http://www.phpclasses.org/
  74. 74 http://www.codeproject.com/
  75. 75 http://www.codeproject.com/
  76. 76 http://www.eclipse.org/swt/snippets/
  77. 77 http://www.eclipse.org/swt/snippets/
  78. 78 http://bendiken.net/snippets/ruby
  79. 79 http://bendiken.net/snippets/ruby
  80. 80 http://rubyforge.org/snippet/browse.php?by=lang&lang=17
  81. 81 http://www.rubyinside.com/8-more-useful-ruby-code-snippets-171.html
  82. 82 http://erikveenstra.nl/rubycodesnippets/index.html
  83. 83 http://rubyforge.org/snippet/browse.php?by=lang&lang=17
  84. 84 http://dotnetslackers.com/default.aspx
  85. 85 http://dotnetslackers.com/default.aspx
  86. 86 http://www.codefetch.com/
  87. 87 http://www.codefetch.com/
  88. 88 http://snipt.org/
  89. 89 http://snipt.org/
  90. 90 http://github.com/cnprog/CNPROG/tree/master
  91. 91 http://github.com/cnprog/CNPROG/tree/master

↑ 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

    Awesome post!! :)
    thanks cameron..

  2. 52
  3. 103

    Interesting list, but you missed:

  4. 154

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

  5. 205

    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!

  6. 256

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

  7. 307


    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.

  8. 358

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

  9. 409

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

  10. 460

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

  11. 511

    Google Shut down CodeSearch :(

  12. 562

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

    • 613

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

      • 664

        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

    • 766

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

  13. 817

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

  14. 868

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

  15. 919

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

  16. 970

    Awesome list!

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

  17. 1021

    Cool, bit old!

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


↑ Back to top