4

Suppose that I have a block of code that represents my own original work (i.e. I am the copyright holder), and that I would like to post this code on Stack Overflow--either to answer someone else's question or to ask a question regarding the code.

Let's also suppose that I want to use this code in my own project as well--either one released under a non-copyleft license like the MIT license, or even a closed-source, proprietary program.

If I post my code onto Stack Overflow, which uses the CC-BY-SA 4.0 license (a copyleft license), am I then required to release my project under the CC-BY-SA 4.0 license? Or am I free to use the MIT license or any other license of my choosing?

1
  • 1
    Just wanted to say this is a great question and I'm somewhat surprised it hasn't been upvoted. +1
    – Greenstick
    Oct 18, 2021 at 6:39

3 Answers 3

6

When you license your creative work under one non-exclusive license such as CC-BY-SA, you are in no way prevented from also licensing your works under different non-exclusive licenses such as MIT. The other license doesn't even have to be an open source license – dual-licensing is a common business model.

You are the sole copyright holder of the creative work. No one else can use your works. By offering licenses, you are giving permissions to other people. But you still retain all your rights. You are not required to comply with these licenses yourself – you are the licensor, not the licensee.

Technically, the licensor of CC-BY-SA 4.0 material does give up some rights. For example, you waive the right to collect royalties when recipients exercise the permissions you gave them through this license (cf section 2.b.3). But that doesn't restrict you outside of that license.

1

If I post my code onto Stack Overflow, which uses the CC-BY-SA 4.0 license (a copyleft license), am I then required to release my project under the CC-BY-SA 4.0 license?

You are not required to, you have released it under that licence. Anyone who complies with the the terms of the licence can use your code.

am I free to use the MIT license or any other license of my choosing?

Of course you are: it’s your code.

However, anyone who uses your code and complies with any licence you released it under is not violating your copyright.

5
  • 2
    Hi @Dale, by 'project', I am referring to a hypothetical later project that will incorporate the code sample that I am posting on Stack Overflow. For instance, let's say that the code sample I'm posting on Stack Overflow is 30 lines [I know the law doesn't depend on how many lines of code--I'm just using the numbers for a reference], but my final project will be 1200 lines of code. I understand that my code sample has been released under CC-BY-SA 4.0. However, If I want to release my final project under the MIT license and not a copyleft license, is that permissible?
    – KBurchfiel
    Jun 26, 2021 at 2:25
  • Basically, I want to make sure that posting a code excerpt doesn't restrict my ability to choose a different license for a project that incorporates that code. If it does restrict my ability, perhaps I'm better not posting on Stack Overflow at all.
    – KBurchfiel
    Jun 26, 2021 at 2:25
  • I don’t understand how “of course you are, it’s your code” is confusing you.
    – Dale M
    Jun 26, 2021 at 3:23
  • 2
    I just wanted to clarify that by 'project', I wasn't referring to the code sample on Stack Overflow, but rather to a larger block of code that would incorporate that sample. But based on your answer, it sounds like I can release all of the final project under the MIT license. That's good. However, because I posted part of that project (i.e. the code excerpt) on Stack Overflow, has that project also been released under the CC-BY-SA 4.0 license? Initially, you wrote "you have released it under that license," but this confused me since this hypothetical project wasn't published yet.
    – KBurchfiel
    Jun 26, 2021 at 3:28
  • @kburchfiel as long as it doesn't incorporate anyone else's edits, you own the whole copyright and can license the code under as many non-exclusive licenses as you want. Even after the two such grants implied by posting on SO (or any SE site), that still leaves you as many as you want. (If it does incorporate substantial edits, you are still fine if the other contributors license their work under the same terms.) And no, posting small pieces of code to SO/SE doesn't magically grant anyone any rights to any larger works, past, present, or future, that you also use it in.
    – SamB
    Nov 30, 2021 at 22:18
1

Let's check the Stack Overflow Terms of Service:

Subscriber Content

You agree that any and all content, [long list of things you can post on Stack Overflow] (collectively, “Content”) that you provide to the public Network (collectively, “Subscriber Content”), is perpetually and irrevocably licensed to Stack Overflow on a worldwide, royalty-free, non-exclusive basis [...]

I emphasized the term non-exclusive, because that's the critical word here. A non-exclusive license means that although you give Stack Exchange a license to use your content, you still retain the right to license it to anyone else under whatever conditions you want.

So when you post some code you created on Stackoverflow, you can still publish it elsewhere under a more permissive or less permissive license if you want.

1
  • By the way: All my code contributions to the Stack Exchange network are dual-licensed under whatever license condition Stack Exchange states in the terms of service and the WTFPL Version 2 as published by Sam Hocevar unless stated otherwise.
    – Philipp
    Nov 30, 2021 at 15:28

You must log in to answer this question.

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