What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

I've looked through a few of the questions about the licensing of posts on SO, but haven't found any really satisfactory answers. Can an answer be used in an open source project (with an MIT license)? I'm not looking to simply cut and paste, because I would need to modify the snippet to suit my project and also because the answer is in a different programming language. Also, if the answer can be used, how should it be credited? Should it just be a link to the SO page? Should it include the user name? Should the user be contacted?

share|improve this question

migrated from stackoverflow.com Aug 28 '09 at 7:34

This question came from our site for professional and enthusiast programmers.

Very related: Do I have to worry about copyright issues for code posted on StackOverflow?. I follow Waffles' suggestion from that discussion and dedicate my code snippets to the public domain to keep things simple. –  Jeremy Banks Dec 10 '11 at 23:14
add comment

6 Answers

Linking directly to the answer (or question and multiple relevant answers) should satisfy the attribution provision of the cc-wiki (attribution, share alike) license that has been selected for SO.

share|improve this answer
add comment

IANAL, but just be honest how you got the code.


You should be able to use the code in your project provided you supply attribution details and source code. Just make sure the license you are using allows for this.


// thanks to RodgerB from StackOverflow
// special thanks to rcar for suggesting I use doubles
// http://stackoverflow.com/questions/169041/how-should-a-so-answer-be-credited-for-use-in-an-open-source-project
private int AddNumbers(double a, double b)
    return Convert.ToInt32(a+b);
share|improve this answer
You should probably cast a and b to doubles before you make the addition, then round them and cast it back to an integer. –  Randy Oct 3 '08 at 22:00
Would an MIT license be compatible? –  VirtuosiMedia Oct 3 '08 at 22:03
Yep, if you are sharing source code and telling the user reading your source where you got the information from. I am not a lawyer though, this is just my understanding. –  RodgerB Oct 3 '08 at 22:05
stackoverflow.com/questions/169041#169060 –  Swati Oct 3 '08 at 22:14
upmodded, this is an excellent function, would read again –  Colen Oct 3 '08 at 22:17
add comment

If the input is important, I would put somewhere (in a credit page/file perhaps): "With help from XyzAtSO given at http://stackoverflow.com/questions/151515/bla-bla" or something along these lines.

Personally, I see my (original!) code snippets here more or less as public domain but giving credit is always nice and appreciated.

share|improve this answer
Some Wikipedians employ a legal "hack" for this - you explicitly place your contributions into the public domain, thus offering an alternative to the license offered by Wikipedia. You've just reminded me to do this here - thanks! –  onebyone Oct 3 '08 at 23:27
add comment

Well, as all content on Stack Overflow seems to be licensed under the Creative Commons Attribution-Share Alike 2.5 Generic license, I think that a link to the answer should be provided. That should satisfy the "Attribution" part of the license.

The "Share Alike" portion is a bit harder, because it requires the code/product to be licensed under the same or a similar license. I cannot tell whether the MIT license counts as a similar license. However, you might be able to find a compatibility matrix or so …

share|improve this answer
add comment

The full text of the CC by-sa 2.5 license says:


"You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan)."

My personal opinion is that this renders the sa CC licenses viral: there is no such thing as a "compatible" license, because the share-alike requirement is that one of an enumerated set of licenses is used, not just "any license with similar terms". Whether your work is a Derivative Work or not depends on what you've copied - seeing a copyrighted implementation of bubble sort doesn't necessarily mean you can never use bubble sort again. If it's not a Derivative Work then the CC license is irrelevant, so you can distribute your work under any license you want, including MIT.

However, I am not any kind of lawyer, and certainly not your lawyer, so my personal opinion is worth what you're paying for it.

Note that CC Deeds (the thing you see when you follow the link in the corner of the page) each have a really tiny link at the bottom, behind a door marked "beware of the leopard", leading to the actual license.

[Edit: I have just added the following text to my userinfo:

"All my original contributions to StackOverflow are placed into the public domain. If this is not legally possible, then anyone receiving a copy of them by any means is granted a non-exclusive perpetual license to use, distribute and modify them, and to distribute modifications, under any license or none, with or without attribution to me. Please note that this license applies only to my original contributions."]

share|improve this answer
Is that text under a license, or may I use it too? =D –  NickAldwin Oct 15 '09 at 19:08
Steve: The Unlicense does exactly what you want, but is more thorough. –  bukzor Mar 10 at 18:56
add comment

Most projects will be unable to incorporate expressive content from StackOverflow due to the ShareAlike element. Neither Apache 2.0 (by extension MIT and BSD) or GPL licenses list it as compatible.

Apache: say to contact the Legal committee, I wouldn't expect there to be happiness regarding CC-SA in software. The same type of thinking would hold for MIT and BSD projects.

FSF: don't explicitly list LGPL or AGPL, but I would expect the same to hold.

Mozilla and Eclipse may be happier with CC-SA and I could see it being feasible that a future CC-SA license could resolve the FSF concerns.

Summary: you probably need to ask each SO answer to license the code differently than the default.

share|improve this answer
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .