Stack Exchange applies CC-BY-SA to all posts. How does this interact with free or open source licences? If someone wants to ask a question about a piece of open source software can they post code snippets into their question or would some licences prevent code being posted under CC-BY-SA?


If it's just small snippets, then that likely falls under fair use. In that case, the license doesn't matter and you are allowed to post them.

Though how small exactly would the snippets have to be is not specified, so you should be really careful about keeping them really small.

  • Is "how small" a matter of the length of the snippet, or whether it can run independently, or whether it is small enough to already exist elsewhere? – trichoplax Jun 27 '15 at 0:49

It depends on the license and the owner, but likely no.


If the code you want to post is licensed under GPL, don't even think about it. GPL has strict share-alike restrictions, so you must reshare under the same license. Posting to SE shares under CC BY SA, so violates these terms. Other licenses may have similar; I don't know them all.


Obviously, if you're the owner then ignore the whole lot of this and do as you like. If you're not, but you can contact the owner, you should consider doing so. You can ask them to relicense the work solely to you because you want to post it to SE (add details about SE and why this is a good purpose), or to make an exception. This relies on their generosity, but many devs will be happy with this.

  • 4
    I'm downvoting, because while from a license perspective this is entirely correct, it ignores fair use. Critical discussion of a work is one of the primary reasons fair use exists in the first place. – Martijn Jun 29 '15 at 11:14
  • Fair use here is critical. Fully copyrighted, GPLed etc materials may be (with some limitations) quoted under fair use. "If the code you want to post is licensed under GPL, don't even think about it" is simply untrue. – Mateusz Konieczny Oct 14 '16 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.