Stack Exchange is announcing the change from CC-BY-SA 3.0 to MIT License and the chaos has emerged.

After a few hours of research, I've concluded that I've been breaking the law (license) since the day I started using Stackoverflow. I've probably copied more than 1 thousand lines of code from Stack Overflow and I've never attributed it to anyone nor I released my software under the same license.

On that matter, how do you even attribute the credit for a snippet of source code? Should my code be like:

 * replace first element of $bar with $baz.
function foo(array $bar, $baz){
     * @author aefxx
     * @link http://stackoverflow.com/a/18577136/1014588
     * @modified Marco Aurélio Deleu
    $key = key($bar);

     * @author rockacola
     * @edit Toby Allen
     * @link http://stackoverflow.com/a/1739717/1014588
     * @modified Marco Aurélio Deleu
     array_unshift($bar , $baz);

    return $bar;

Because I gotta say, this gives me more trouble than solution. It would be easier to just ban Stack Overflow from my Google Searches.

This discussion goes back to 2008 and on top of it all, I have to check the user's profile to make sure which license I'm allowed to use?

Bottom line is that I'd like to be able to post snippets of my codes in questions, answers, code reviews and whatever and be able to learn/copy/change/profit from other questions, answers, code reviews and whatevers without having to worry about legal consequences. I want Stack Overflow to be a place where I get help and give help, not a place to cause me legal consequences.

Is this achievable?

  • 2
    See: meta.stackoverflow.com/questions/286582/…
    – WBT
    Commented Jan 2, 2016 at 15:13
  • 3
    Why would you be copying a thousand lines of code from Stack Overflow?
    – TRiG
    Commented Jan 2, 2016 at 18:43
  • 5
    Why would you be copying one line of code from Stack Overflow? If you can't remember "array_unshift" while flipping between browser and editor, you may wanna get some rest.
    – Shog9
    Commented Jan 2, 2016 at 19:12
  • 7
    Why wouldn't I copy and paste? Why would I go through the trouble of remembering and typing it out what is already digitally written on the screen? Not to mention that Stackoverflow has a lot of answers that consist of more than 1 line of code. Commented Jan 2, 2016 at 20:40
  • I guess Shog9 meant why you need to copy a function name like in your sample. Maybe your sample is not what you actually meant as 1000 lines or code. Commented Jan 2, 2016 at 21:32
  • 11
    @PatrickHofman When I put effort into answering a question and help someone overcome a problem, I don't expect them to put my name and the link of the question into their closed-source project. That's just unnecessary and give them an extra work. Commented Jan 2, 2016 at 21:45
  • 1
    True, then the OP can post that he doesn't want attribution. And just put in the url of the post in your code, as suggested in my answer. That's all. Commented Jan 2, 2016 at 21:58
  • 7
    I'm the director of Stack Overflow Communities, and pretty involved in this project. tl;dr; - You don't really have anything to worry about, and I'm working on an answer in that direction. We're still in a bit of flux after the great feedback we received when we announced the change - so it's kinda hard to answer this completely while we still have some pretty important decisions to make before we open another discussion with a revised scheme. I'm going to try to bump up some meetings to make these decisions so the answer I want to write has a firmer base. Hang tight.
    – user50049
    Commented Jan 4, 2016 at 6:33
  • 4
    @TimPost, "You don't really have anything to worry about". The OP admits breaking the license terms on a significant scale (1000 loc!) and you say, "Yup, fine, whatevs"?! That's a gross abdication of your (SE's) duties and moreover a breach of your (SE's) contract as a licensee of the content in question, because it implies you are granting the OP additional rights that are not in fact yours to grant.
    – user136089
    Commented Jan 17, 2016 at 3:27
  • @MarcoAurélioDeleu, you should ignore TimPost's reassurance above. He is not in a position to legally indemnify you against the licensors of the content you say you plagiarized, if they decide to pursue you for infringement. For good reason, "the conditions of a Creative Commons license automatically apply to the content licensed under it, and bind users of such content even without expressly agreeing to, or having knowledge of, the conditions of the license." (Source.) Rectify instead.
    – user136089
    Commented Jan 17, 2016 at 3:52
  • @sampablokuper I'll be adding an answer tomorrow. A part of the new license rollout was going to include some information for people that aren't just scraping our stuff and didn't understand the requirements. We'd rather help people understand and correct honest mistakes (just like busybox works with hordes of people that don't understand the GPL and are technically breaking the license). Gross abdication? I said I'd post an answer when more things were clear, and I will. And where did I say "Yep, fine, whatevs?" Don't put words in my mouth.
    – user50049
    Commented Jan 17, 2016 at 17:57
  • @TimPost, "where did I say "Yep, fine, whatevs?"" I was, very obviously, paraphrasing your statement, "You don't really have anything to worry about," which is semantically equivalent to my paraphrase of it. "Don't put words in my mouth." I'm not going anywhere near your mouth, Tim.
    – user136089
    Commented Jan 17, 2016 at 18:01
  • @sampablokuper That wasn't paraphrasing. That was hyperbole, and borderline ad-hominem. I will post an answer tomorrow, you're welcome to comment then. Have a great (rest of) the weekend :)
    – user50049
    Commented Jan 17, 2016 at 18:04
  • @TimPost, "just like busybox works with hordes of people that don't understand the GPL and are technically breaking the license." AFAIK, the BusyBox licensors first ask violators to rectify their violations by complying with the GPL. This is analogous to my advice to Marco above ("Rectify") and is in marked contrast to your advice to him ("You don't really have anything to worry about"). If BusyBox doesn't obtain compliance after requesting it, then they may sue (rightly so) & have sued successfully multiple times. Also, to re-iterate, SE is not the licensor.
    – user136089
    Commented Jan 17, 2016 at 18:11
  • @TimPost, "That wasn't paraphrasing. That was hyperbole." I'm unconvinced a semantically equivalent statement can be anything other than a paraphrase, and I don't believe my paraphrase was any more hyperbolic than yours.
    – user136089
    Commented Jan 17, 2016 at 18:18

4 Answers 4


I think that there is a piece missing. Not every line of code on Stack Overflow needs attribution, a year ago, a week ago, yesterday, or next year. In copyright, there is something called the threshold of originality. In the United States, to be eligibility for copyright requires that the work being copyrighted required some minimal degree of creativity to make.

Unfortunately, I'm not able to actually define what "minimal degree of creativity" actually means. Although you can probably take a well educated guess. Looking through my answers that include code, I haven't found any on Stack Overflow that actually required creative effort to put together.

Let's assume that all of the code that you copied was like mine and didn't meet the threshold of originality and couldn't be copyrighted. That means that you can't put a license on the code. The requirement for attribution comes from the license. So that little piece of code? Nope, no need to provide attribution.

All of that said, it is a good idea if you start providing attribution, even when it's not legally required. But because there's no license to specify how to attribute the code to the owner, you can attribute in the way that you feel is appropriate.

I would exercise a lot more caution on large code blocks, especially when you get to functional units - functions and methods, classes, and similar. The code posted in questions and answers on Code Review and Programming Puzzles & Code Golf are probably more problematic than most of the code on Stack Overflow. Likewise, the entire shell scripts posted on sites like Ask Different or Unix & Linux may also be covered under copyright. That's when you may run into issues, and why revisiting the license terms is very important.


All code you have copied from Stack Overflow in the past already required attribution. The legal page says you need to link to the original post and the authors profile, both on the Stack Exchange domain (so not a scraper).

The new license is giving you more freedom since it is allowed to copy code without attribution.

The MIT announcement page says:

Contributors agree to give code users permission to ignore the MIT License’s notice preservation requirement, as long as users give reasonable attribution upon request of the copyright holder (or Stack Exchange on behalf of the contributor).

So no attribution required as long as the author or Stack Exchange doesn't ask you to.

The above is outdated. The new proposal says attribution is required. Now that proposal is put on hold. Clearly, they are not sure what it will be. We have to wait until the final document is out.

It also recommends this:

Add a comment to your code that links back to the post where you found it

That is just a single line of comment, which is a lot less than your post has. That seems to be enough according to the license announcement.

And that doesn't mean you have to attribute every use of a framework function, like in your sample. If you use the general idea behind an answer, like the use of a framework function like array_unshift, there is no need to attribute that since you didn't actually copy the code block.

  • 5
    As of today's update attribution is required. Commented Jan 14, 2016 at 22:06
  • Indeed. I have seen that too. Commented Jan 14, 2016 at 22:21
  • 4
    "All code you have copied from Stack Overflow in the past already required attribution" - repeating this does not make it true. Most code snippets on SO are demonstrations of generic language features, and nowhere on this planet those require attribution (I'm pretty sure that this is what Marco was trying to say). Insisting that hello-word-type programs require licences and attributions is absurd, not to mention un-enforcable. Commented Jan 15, 2016 at 10:11
  • 1
    The license and TOS doesn't make any distinction between them, so the TOS isn't clear on this. As a general rule, if it is just a method call to a framework function, I agree it doesn't fall under the license (you could have copy that from the official documentation). @EikePierstorff Commented Jan 15, 2016 at 10:14
  • @PatrickHofman, I think this the crux of the matter. What SO has is a general rule (attribution) that covers only exceptions (those rare posts that actually show code worthy of attribution). I don't think this is a good idea, and I know that I am not alone here. Commented Jan 15, 2016 at 10:35

On that matter, how do you even attribute the credit for a snippet of source code?

Assumptions: The code from the answer is copyrighted (if it’s not, you don’t have to attribute), and licensed under CC BY-SA 3.0. So it’s case {3} from my other answer.

Your attribution example is missing an important element: You have to note how the original work is licensed. (SE’s “Attribution Required” page misses to list this requirement, but it’s nevertheless legally required.)

A simple attribution could look like this:

 * @author unor
 * @link https://meta.stackexchange.com/a/272269/
 * @license http://creativecommons.org/licenses/by-sa/3.0/

If you modified the code (and if this modification resulted in an Adaptation), you have to indicate that changes were made (and optionally, which):

 * @author unor
 * @link https://meta.stackexchange.com/a/272269/
 * @license http://creativecommons.org/licenses/by-sa/3.0/
 * @modification The original code has been modified.

And yes, your work has to be licensed under CC BY-SA 3.0, too. In case of an Adaptation, you could license it under a compatible license in addition (e.g., CC BY-SA 4.0 and GPLv3).


I'd like to be able to post snippets of my codes in questions, answers, code reviews and whatever and be able to learn/copy/change/profit from other questions, answers, code reviews and whatevers without having to worry about legal consequences. I want Stackoverflow to be a place where I get help and I can help, not a place to cause me legal consequences. Is this achievable?


There are two separate issues: Contributing your code to Stack Overflow, and taking code from Stack Overflow.


As long as you solely own the copyright for the code, and you accept that by contributing it you are agreeing to license it to Stack Overflow so they can license it to their users, then you can go ahead and contribute your code verbatim.

As long as you have been given permission by the copyright holder you can do the same. This might be the case where you have code that answers a question inside existing code who you've already assigned the rights to your employer or client. They need to give permission, and once you've received that you're fine.

If neither are true, but you know the answer, just don't cut and paste from existing code bases. Start writing the answer, write the code with the caveat, if needed, that you haven't tested it, or simply refer to the methods, classes, generic algorithm name they need to look up in documentation, and link to those on other sites. There's no need to copy from your existing code to answer most questions. Most code answers are short enough, anyway, that you can write something altogether new.

This only covers code snippet copyright and licensing, though. If there's a trade secret, or client/company specific knowledge that would help the asker, you might want to make sure that you own the idea and haven't signed it away before giving that away - it may not be code, but it may still be covered by agreements and contracts you've made with others.


It really doesn't matter what license Stack Overflow adopts. I recommend you never copy code as-is from the site. Instead, learn a little about clean room reverse engineering and follow those tenets as closely as you believe necessary to separate your output from your learning.

A simple process might be the following:

  1. Develop per your normal methods, using official documentation and other relevant resources which you won't be tempted to use cut-n-paste on.
  2. Write down questions and problems you have if they don't prevent you from proceeding. Make notes in text and code where these problems exist so you can easily revisit them later. Code for as long as you can.
  3. When you can't proceed any further, shut down your development environment and open your learning resources where you might be tempted to cut-n-paste from, along with your text notes.
  4. Research your questions. Write the notes and answers needed in your text notes. Do not cut-n-paste. Particularly valuable are references to classes and methods you might need, and short descriptions and sketches of algorithms. Don't write code at this point - it's too easy to write what you're seeing, which isn't much different legally from cutting and pasting. Use a fake human readable code if you need to take step by step notes about a complex algorithm. Do not go back to your development environment if you have questions, make a note and answer it later.
  5. Close your research windows. Restart your development environment. Open the resources you need from the notes that point to official sources of documentation and other resources that are "safe" to use while developing. Start writing code again.

This isn't a perfect clean room reverse engineering, you can go much more deeply down this, but with proper notes you may be better protected from possible legal issues. You will not need to perform any attribution except since you never copied anything, but you might want to keep links in your notes should you have to refer to them later.

If you properly organize your notes then they will act as excellent documentation for later maintainers as well as legal evidence of a valid clean room reverse engineering method.

  • 4
    "learn a little about clean room reverse engineering" I'm sorry, but no. If we have to follow some asinine procedure just to use a resource that exists for us, then screw it. We'd be better off using a forum than SO. Commented Jan 15, 2016 at 0:50
  • @NicolBolas they all have the same problem. Please go ahead and describe, then, the license that you would find acceptable which wouldn't require anything like this.
    – Pollyanna
    Commented Jan 15, 2016 at 4:15
  • Have we all gone mad?
    – JoelFan
    Commented Jan 15, 2016 at 21:36
  • 1
    @JoelFan your statement presupposes a period of time when we were not mad.
    – Pollyanna
    Commented Jan 15, 2016 at 22:01
  • I'm not a lawyer, but this seems like bad advice to me, even if you're in an organisation big enough to care about such legal nonsense (which not all of us are). Clean room development is not a legal defence against copyright infringement (at least in the US, which is the only place for which I can find references), and working in a clean room removes your ability to compare your code against the original and avoid accidentally writing identical code snippets. It's non-obvious whether this results in more or less legal risk.
    – Mark Amery
    Commented Jan 17, 2016 at 16:58
  • @MarkAmery As I understand it, clean room development isn't a copyright violation because it isn't copying at all. So no defense is necessary. By contrast, "fair use" is a defense to copyright infringement; in such cases, there was copying but it's still allowed.
    – jkdev
    Commented Jan 17, 2016 at 21:30
  • 3
    Also: "If Defendants did indeed follow clean room procedures, the Plaintiffs would be unable to make the necessary showing that Defendants had access to the copyrighted work." (Source: Clean Room Defeats Software Infringement Claim in US Federal Court, quoting the court's written opinion in Nordstrom Consulting, Inc. v. M&S Technologies, Inc. (N.D. Ill. 2008))
    – jkdev
    Commented Jan 17, 2016 at 21:32
  • actually great ! Commented Dec 26, 2016 at 16:16

You must log in to answer this question.

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