Please Read this: The MIT License – Clarity on Using Code on Stack Overflow and Stack Exchange

All the content in Stack Overflow and other Stack Exchange (even this question) is under Creative Commons BY-SA 3.0 with attribution required, so you might find this questions interesting:

When is attribution required?

The article Attribution Required from Jeff Atwood explains how you need to give attribution, however when you read it, looks like is talking when you republish a content from Stack Overflow or other Stack Exchange in a website or blog in any public manner, but what if I'm using code from an answer or question in my own code that is intended to be sold? How attribution should be done? Is needed? Also what if I'm just using small pieces of code that I learned or copied and paste it from an answer or question and I adapt it to my own code? Is attribution needed?

If you had read the license, it says that is ShareAlike this means that "If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original." In some way you might think that if you use small pieces of code from an answer or question now your work needs to be licensed under Creative Commons BY-SA 3.0 too, but when I read the ShareAlike Interpretation I saw this:

The ShareAlike condition applies only for works considered adaptations under copyright law, not simply in collections with other works (also referred to as mere aggregations).

So it means that even if you use small pieces of code from answer or questions, your entire work doesn't need to be licensed under Creative Commons BY-SA, too, at least it be an adaptation from it not just small pieces of code, am I right?

  • 1
    "If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original." Isn't using small pieces of code considered "building upon" the material?
    – 0x6C38
    Jan 18, 2016 at 20:45
  • 1
    I'm kind of curious why it matters.(yeah read the SO links) Code is an arrangement of predefined variables and often at SO you aren't dealing with entire apps, just snippets. So claiming ownership over a snippet which merely arranges pre-defined variables seems a bit litigious to me. As a contributor, it has never even crossed my mind that I may own the rights to some small snippet I've posted. That mindset seems foreign to me. And actually trying to enforce any such claim would be ludicrous in my opinion.
    – Scott
    Jan 18, 2016 at 21:30
  • Yes i think the same, if you copy 5 lines of code doesn't mean that now you must give your entire work for free or with the same license, you are the owner of the code you wrote it and youc can do with it whatever you want, i already contacted Creative Commons and in the reply i got some link to understand the ShareAlike Clause: wiki.creativecommons.org/wiki/ShareAlike_interpretation if you read it you will understand a little more about it, to be an adaptation it must be taken from the original work, "not simply in collections with other works (also referred to as mere aggregations)." Jan 18, 2016 at 22:30

1 Answer 1


First off, you need to determine whether the code is even eligible for copyright. Something like this probably doesn't cut it:

public class HelloWorld 
    public static void sayHi() 
        System.out.println("Why hello there!");

I use Stack Overflow answers all the time. I don't copy the code directly, but I take the ideas and rewrite them for use in my own implementations.

With Creative Commons, it's tricky. It's known that CC BY-SA is highly discouraged for code, and this is the reason why Stack Exchange is having this licensing drama: to help end users, and contributors to stay in the clear.

To answer your question, you need to look at a few key components:

  • Are you implementing your own version of the snippet?
  • Is your entire program based on that code in the SO Answer?

If you answered "yes" to the first question, then no. You probably don't have to worry about licensing. While you could have a section in your program to attribute them (I keep a comment, or a little section in a file to say Thanks), that's just about as much as you need to do.

If you answered "yes" to the second question, then you've probably got a problem. Remember that snippet I made above? Suppose it was somewhat more complex, and it was a full, working problem. If you make changes where without my code, your program wouldn't be running, then you're probably creating an adaptation based on my work. You'd probably have to license that under the Attribution Share-Alike license.

To summarize, your over thinking it. Just say thanks, be sane and don't directly cope code, and you're in the clear. Happy coding :)

  • I'm agree with that, thanks for taking the time, but i read that from 1 March now the code will be licensed under MIT in SO and SE if your code is not MIT licensed you can give attribution in the code. For more info: meta.stackexchange.com/questions/272956/… still it is on a big discussion, might you could give your opinion there. Jan 18, 2016 at 22:48
  • @RodrigoCalix Pretty sure I have, but my answer's probably all the way at the bottom :/
    – Zizouz212
    Jan 18, 2016 at 22:49

You must log in to answer this question.

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