Just how long/non-trivial does code have to be before the CC license apply to it? (for Stack Overflow answers)

For example, I would assume that if someone posted a long function, then the code would be put under the license automatically. However, an answer to the simple question "How do I exit out of a function?" would not be copyright-able because it would be standard code.

As an example, would the code in the first answer to the question here be considered copyright-able?
I think it is not but maybe it is?

1 Answer 1


And just because this is a little complicated, there's a bunch of useful reading, written by people who do work for SE. If you're really in doubt, talk to a lawyer in your local jurisdiction, preferably someone who knows IP law.

To a large extent the CC-wiki licence in use is designed to be for posts more than code - and this blog post sets out the 'spirit' of the licence, with respect to Stack Exchange.

In a sense your whole answer is a 'work' under CC - and part of that, in theory, is your code. On the other hand, that CC doesn't work that well for code - something that's been noted. One proposed solution was to licence any code under the MIT licence but folks hated that.

There's also this post by Jeff Atwood (whose word counts for quite a bit in these parts but isn't a lawyer) - which gives a common sense interpretation of it.

The cc-wiki license seems pretty clear to me on this point: free to remix and reuse, as long as you attribute and use a similar license.

That said, a snippet of code falls under excerpt category and thus should be free to use under fair use. Heck, we don't even support giant masses of code being posted, so to me, by definition, everything would be an excerpt. We're not sourceforge, github, or codeplex.

So essentially, while it's not public domain, using some code, especially 'trivial' snippets should be fine under fair use. To a certain extent 'that' sort of social contract - the understanding people will use your code or other content to some extent - is how this place even works.

If it's your own code, feel free to stick a more permissive licence on it as well. If it isn't and you feel it may be an issue, talk to a lawyer who gets this stuff.

You must log in to answer this question.

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