Is there a default licence applied to code included in an answer, and if so, what is it?


1 Answer 1


Yes. All submissions to the Stack Exchange Network are automatically licensed under the Creative Commons CC-BY-SA licence. (See section 3 of the terms of service.)

Additionally, you can license your work under additional licences, if you wish. For example, as stated in my profile, I explicitly release all my code snippets posted on Stack Overflow under (essentially) a no-rights-reserved licence.

ETA: To address user unknown's point about how opting out would be "prohibited": This topic has been flogged to death, but, in short:

  1. You are required to license your work under CC-BY-SA in order to post to any of the Stack Exchange sites. (See section 3.)
  2. Creative Commons licences are not revocable. Once you license a work under such a licence, no action on your part can retract the licence, unless a licensee has violated the terms of the licence (and even then, the revocation applies to the violator only, not to the general public). (See section 7b.)

ETA2: IANAL, and I don't think it's been tested in court, but the "enforcement of CC-BY-SA" thing has definitely come up at Stack Exchange. There was a case not so long ago where a user decided he wanted to nuke all his posts, saying that it's his right to do so as copyright owner.

The moderators disagreed. Creative Commons licences cannot be revoked, so the moderators had a right to revive his posts and keep them available "forever".

The only way to violate the terms of service in this regard (that I know of; IANAL) is to post something you don't hold copyright to. In that case, the copyright owner can file a DMCA request to Stack Exchange, and that content will be promptly removed.

If you post something you do hold copyright to, then you are licensing it under CC-BY-SA. You cannot later claim a copyright violation (for actions that are allowed under CC-BY-SA, by a person who hasn't had their licence revoked for previous violations). Wikipedia works the same way:

By clicking the "Save Page" button, you agree to the Terms of Use, and you irrevocably agree to release your contribution under the CC-BY-SA 3.0 License and the GFDL. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.

If you are suggesting that Stack Exchange should include similar verbiage below all the post boxes, you should post such a suggestion on Meta Stack Overflow.

  • \$\begingroup\$ Thanks for the comprehensive answer. Just to clarify, is it possible to opt out of the default (CC-BY-SA) licence, or does specifying another licence mean the code is dual-licensed? \$\endgroup\$
    – Armand
    Commented Nov 24, 2011 at 6:44
  • \$\begingroup\$ It'll be dual-licensed. It's not possible to opt out of CC-BY-SA, in part because all the site content is available to the public under that licence. \$\endgroup\$ Commented Nov 24, 2011 at 19:17
  • \$\begingroup\$ Thanks, that's very clear now. \$\endgroup\$
    – Armand
    Commented Nov 25, 2011 at 6:20
  • \$\begingroup\$ I wouldn't be too sure about the possibility to opt out. How should it be prohibited? According to my knowledge of the law (ianal), it would be a violation of the usage terms of the SE-site to reserve the rights or to restrict them, but from violating the terms of usage a different license as intendet and proclaimed by the author can't be derived. Don't get me wrong - I don't suggest such license battles. Maybe it depends much on the locale laws, but which laws apply? From the SE-site, from the code author, from the user? \$\endgroup\$ Commented Nov 29, 2011 at 23:25
  • \$\begingroup\$ @user unknown: I've updated my post to address your points. \$\endgroup\$ Commented Nov 30, 2011 at 21:21
  • \$\begingroup\$ Well, you wrote an answer, but I don't think it is valid. For example, in Germany, you need a license for software you use, and a license can only be granted by the author of the software (exception: programming as a job: the company owns the permission to license the software). A violation of the usage terms of the SE-site does not automatically create a valid license. If I explicitly deny the permission to use the software I can't get forced by general terms and conditions. Maybe it is different in the US, but I wouldn't expect so. \$\endgroup\$ Commented Nov 30, 2011 at 23:37
  • \$\begingroup\$ @user unknown: Updated post again. tl;dr: It is enforceable, even if it's not been tested in court. Wikipedia works the same way. \$\endgroup\$ Commented Dec 1, 2011 at 21:45
  • \$\begingroup\$ Well - I would assume to fail on court if I later claim, that the code was not published under license CC-by-STH, but I could meanwhile, while posting a piece of code, restrict the copyright, so that every potential user would see it. To construct a case: You claim to have a quickest-sort-algo, and I claim that I have something faster. To prove that I'm right I show you the code, but prohibit its usage, apart from veryfying that I'm right. Well - I won't do such a thing (and don't have a quicker-than-quickest-sort-algo), but as an example... \$\endgroup\$ Commented Dec 1, 2011 at 23:12
  • \$\begingroup\$ @user unknown: Sure, if you attach a statement that you refuse to use CC-BY-SA with your post, that would take effect, legally speaking. However, your post would be removed by a moderator for being non-compliant with the site policy. \$\endgroup\$ Commented Dec 1, 2011 at 23:17
  • \$\begingroup\$ Yes, I think so. \$\endgroup\$ Commented Dec 2, 2011 at 2:10
  • \$\begingroup\$ @user It requires implicit agreement with the CC-BY-SA licence to post. Given that as a prerequisite, any claim that you posted it under contrary terms is null/void/erroneous/untrue. You can't make an agreement and then change the terms unilaterally. No? (IANAL) \$\endgroup\$ Commented Dec 8, 2011 at 5:13
  • \$\begingroup\$ The license agreement is on a page in the FAQ or somewhere. If somebody - let's say 'me' - if I write explicitly, that I don't grant permission to my code, I'm violating the terms of use, which is a kind of contract of the SE stuff and me, but that doesn't create a contract between me and the user of the code. At least according to german law, nobody except me can grant permission to use my code, and if I don't do it, the EULAs can't do it for me. But I guess it is a very theoretical question, since the code would soon be deleted. \$\endgroup\$ Commented Dec 8, 2011 at 6:50

You must log in to answer this question.

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