The Creative Commons Attribution-Share Alike license that all Stack Overflow contributions are licensed under states:

  • Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

The one that I'm worried about is the phrase build upon this work. If I find an answer to my problem that includes a code snippet, and I use that snippet (or some part of it, or something based on it) in my code, do I now have to release my code under "the same or similar license to [cc-wiki]"?

If so, doesn't that mean that code provided in answers on Stack Overflow should never be used in non-copyleft code?

2 Answers 2


For small snippets, it's unlikely copyright even subsists in the "work". Furthermore, in the US, fair use doctrine applies.

If you're routinely cutting and pasting large blocks of code that are clearly copyrightable out of Stack Overflow, I'd say you have a rather more serious problem.

  • 1
    Agree, +1, additionally Creative Commons is not supposed to be used for code. See meta.stackexchange.com/questions/3646/… Commented Jun 17, 2010 at 7:39
  • 1
    But shouldn't Stackoverflow be clear about this, rather than letting this be up to interpretation?
    – BRH
    Commented Jun 17, 2010 at 20:57
  • @BRH: SO is clear about this. Posts are under CC-BY-SA. Beyond that, what I've stated applies to everywhere else you'd find code snippets, too. It's basic copyright law, which is something all developers should familiarize themselves with. It's no more up to SO to provide that education than it is any other website. (And trying to do so could be dangerous to all parties, since the exact rules will vary by jurisdiction.) Commented Jun 18, 2010 at 6:47
  • 2
    Mostly this seems a repeat of meta.stackexchange.com/questions/25956/… I agree with David Thornley's part of that thread, and I don't see that small snippets are necessarily covered by merger doctrine, or anything implying fair use doctrine would offer much protection (looking at both ISBN 9780596517960 and Wikipedia's Fair Use page). I do agree that this is no reason for SO to change how it does things. Anyone concerned with CC-BY-SA shouldn't be including SO content.
    – Hen
    Commented Jun 18, 2010 at 7:38

I work on several open source projects that require copyright assignment for contributions that are more than trivial.

In almost all cases, 'trivial' is defined as creating or modifying more than ten lines of code.

Nicholas is correct, I just wanted to chime in with a more specific number. Would 12 lines of code be non-trivial? Probably not, ten lines is just where several major projects (Cherokee being one) draw the line at when to ask for a copyright assignment. I believe its the same for the GNU project (or other code that the FSF owns copyright for).

I think the largest block of code I used from SO was 15 lines long, and probably the only time that I used (most of) a function that someone posted as an alternative to using a full blown lexical parser just to deal with the workings of one string.

You must log in to answer this question.

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