6

Per default, code snippets posted on Stack Overflow are licensed under CC BY-SA-*; see https://stackoverflow.com/help/licensing. This includes a share-alike obligation and attribution obligation, both killing the idea of creating a prospering source of public code snippets/tiny solutions that serve humanity's software development and make the world a better place. I assume that I will not be able to change the licensing model of Stack Overflow in general. Therefore, I would like to provide at least my work in a maximally permissive way (e.g. BSD-0).

On the one hand, in former discussions, there are posts that claim you could do this by comments in

On the other hand, https://stackoverflow.com/help/licensing does not mention an option of post-specific or user-specific licenses and sounds very factual about CC BY-SA:

[...] all publicly accessible user contributions are licensed under Creative Commons Attribution-ShareAlike license as follows [...]

This raises my questions:

  1. What is true? Can I specify the license of my code snippets individually, or does Stack Overflow as host own the right to specify this without exceptions?
  2. If possible, how can I do this correctly a) per code snippet and b) per profile?
  3. Stretch: Do you see any option to change something on Stack Overflow in general, e.g., changing the general license concept or at least updating the documentation to mention user-/post-specific licenses?
4
  • The terms of use are quite clear. The license is specified already, and is the same for all users, regardless of what armchair pseudolawyers think they can make true by fiat.
    – Nij
    Nov 1 at 6:02
  • 12
    @Nij ToS explicitly says that CC BY-SA licensing is "non-exclusive". Nothing stops you from dual-licensing with any other license. Nov 1 at 6:24
  • 1
    Yes, a copyright-holder can do what they like with their copyrighted material. However, posting it on Stack Exchange requires it be released under CC-BY-SA, nothing more and nothing less, regardless of what else a user says beyond that or to the contrary.
    – Nij
    Nov 1 at 7:18
  • 2
    I dare say most users don’t care about sharing and usage rights. I used to link to SO answers that I took code from simply out of courtesy to fellow devs so that they could add context to the bugs i had introduced into the system.
    – user960635
    Nov 1 at 7:19
6

You can specify licenses for your code, in addition to CC-BY-SA. You don't transfer the copyright in your code to Stack Exchange, so you can grant users additional licenses to your code. If that extra license is maximally permissive, then there wouldn't be any reason to use CC-BY-SA of course.

You can dual license your code snippets individually, or as a whole. If you want to add a dual license to a particular code snippet, I would recommend using SPDX license identifiers to identify the license in a standardized way. Using SPDX identifiers on code snippets what Google makes employees do when answering questions on Stack Overflow.

// SPDX-License-Identifier: CC-BY-SA-4.0 OR 0BSD
function helloWorld() {
    console.log("Hello, world!");
}

You can also add a note to your profile like:

In addition to CC-BY-SA 4.0, you may also use code snippets authored by me on Stack Exchange under the terms of the BSD Zero Clause License:

Copyright (C) 2021 by Smitop

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Adding a note to your profile relies on reusers looking at your profile to find the extra license grant though.

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