Possible Duplicate:
Do I have to worry about copyright issues for code posted on StackOverflow?

A very basic doubt: the answers that are quoted on SO, do they come under any license?

Is it OK(/Legal) to copy whole/parts of code provided in answers by users?

I personally make sure to just take cue from the idea and try to re-write the solution but it might not be a case for every problem, hence the question.

My main concern is if I ask a particular question for which someone gets answer off the net and pastes it and that particular code was under some license. This can also be for ideas/solutions provided by users.

I did not find anything on FAQ or previous posts regarding this.

  • Ivar (marked post as community wiki just in case)
  • My code samples always have integrated copy protection. It will destroy your computer if you run it ;)
    – Felix
    Commented Jun 23, 2010 at 23:18
  • @Felix, next time, i will think twice before i look at the code in your answers :D Commented Jun 23, 2010 at 23:38

1 Answer 1


They're licensed under CC-BY-SA, so your code must be under CC-BY-SA as well if you want to copy snippets, and your code probably isn't. See the CC-wiki logo at the footer of trilogy sites.

  • ahh..i missed that...thanks! - ivar Commented Jun 23, 2010 at 23:25
  • How is the CC-BY-SA "viral" as it's described here? Even ignoring fair use (which possibly allows snippet use already), the full license clearly has an "exception" "to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;", where "Collections" is pretty broadly defined. At worst, if you kept your SO code in one place and/or, eg, MPL'd files w/ SO code with attribution, your "Collection" would be fine/unaffected, right?
    – ruffin
    Commented Aug 25, 2013 at 17:52
  • 2
    Are you sure about source code having the CC-BY-SA license? It seems like the regular practice is to give the CC license to the posts, and give the source code a software license. CC-BY-SA isn't meant for software (as the creators of CC-BY-SA have stated). If source code is really licensed with it, shouldn't they change that? I mean, MIT would likely be a lot better, and wouldn't make it so you couldn't use your software in most open source, free-software projects. CC-BY-SA isn't compatible with the GPL, which poses a big problem considering stackoverflow's popularity. Commented Sep 26, 2014 at 11:12
  • However, it's interesting to note that although the code is available under the CC-BY-SA, the posters who own the code can release it under other licenses, too. So, someone could give their code an additional license to choose from manually (but the code would still be available as CC-BY-SA, too). So, there's no need to link to code from pastebin or such to keep your own code GPL-compatible. Here's a quote from the CC-BY-SA license: "… Licensor reserves the right to release the Work under different license terms …" (But the additional licenses can't revoke the CC-BY-SA license.) Commented Dec 9, 2014 at 21:42
  • @ruffin, So how would you define "fair use"? Is copying a function off a page considered "fair use"? What if we repeat that by x10 or x50 on different pages?
    – Pacerier
    Commented Apr 12, 2015 at 12:22
  • 1
    @Pacerier For x10-x50: IANAL, and neither is Techdirt, but, for example, "Pastiche without a specific point to make—a collage or mashup--can also be a fair use." I think someone'd be hard pressed to win a case against you if you had a significant codebase with 10-50 snippets from different SO posts (or a codebase artfully created with only SO snippets). That said, again, IANAL, this doesn't constitute legal advice, this is why I Unlicense my SO code, and why I wish SO would change their license.
    – ruffin
    Commented Apr 12, 2015 at 22:50
  • @ruffin, I've heard that there are problems with Unlicense, that it's just a toy and doesn't work in any legal sense.
    – Pacerier
    Commented Apr 13, 2015 at 12:20
  • @Pacerier Interesting link. Looks like it might have issues in "non-commonwealth" states, like Germany and Japan. What Rick misses (or doesn't care to argue) is that the Unlicense's "salad" attempts to handle such cases. Idk. IANAL. The Unlicense's "stated" intent seemed an improvement over CC-BY-SA to me. Key for me is that the CC license isn't meant for code, so I dual-license SO posts w/ a license that's better than CC-BY-SA.
    – ruffin
    Commented Apr 13, 2015 at 17:53
  • 1
    @ruffin, True, CC doesn't seem to fit nicely when used for code (unless CC0). But I believe it can stand in courts. Things will get interesting when someone (in the future) links to actual precedent cases.
    – Pacerier
    Commented Apr 14, 2015 at 7:28

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