Many Wikipedia articles contain code or pseudocode samples. I implemented a pseudocode snippet in a concrete language and am planning to use it in one of my projects. There's another question on here asking about the usage of such code in commercial projects. In contrast to that question, my project will be non-commercial and open source and I was wondering how to properly include such code snippets without violating reuse terms.

In particular, one of the licences recommended by Wikipedia is the GNU Free Documentation Licence. The very last section describes how to use this license, but this seems to apply to more traditional "documents" instead of source code. There's also a recommentation to publish any code separately under the GPL but most code snippets published on Wikipedia don't seem to abide by this. So my question is whether (and how) I can still use those snippets (or reimplementations thereof) in open source projects.

  • It's worth looking at the references to see where Wikipedia got the algorithms you're interested in. A quick search reveals that many algorithms on Wikipedia appear to be copied straight from programming books such as Programming Pearls and Cormen et al's Introduction to Algorithms.
    – Brandin
    May 4, 2019 at 4:41

2 Answers 2


When merely copying small snippets of code, it may be worth considering whether the use could be covered by a copyright exception, such as fair use in the US. Because if some exception applies you won't have to consider the licensing. You would still have to properly attribute the snippet, of course. Note also that while pseudocode is copyrightable, the underlying algorithm cannot be copyrighted.

If no exception applies, you would have to follow the license under which you acquired the snippet.

Wikipedia is generally dual-licensed under the GFDL and CC-BY-SA 3.0, though individual pages may differ (that should be noted on the page, though).

The GFDL can be understood as a historical artefact. Wikipedia originally used this license. However, the GFDL is highly incompatible with other licenses, and is geared towards books rather than websites. Compliance can be rather cumbersome. It is not compatible with any licenses that are used for source code.

A later version of the GFDL added a relicensing clause that made it possible for Wikipedia (but no one else) to relicense to CC-BY-SA 3.0. Wikipedia exercised that clause, and has been using dual-licensing with GFDL/CC-BY-SA 3.0 for roughly a decade now.

The CC-BY-SA 3.0 license has a much better compatibility story. In particular, you can choose to license adaptions a later license version, CC-BY-SA 4.0 allows you to use a compatible license, and Creative Commons has named the GPLv3 as a compatible license.

That means the full list of licenses that you can use code snippets from Wikipedia under include:

  • GFDL (unversioned)
  • CC-BY-SA 3.0 (explicit dual-license, and compatible licenses per GFDL 1.3 section 11)
    • compatible licenses per section 4(b) (adaptations only!)

So an open source project really only has the option to copy code snippets from Wikipedia if the project uses GPLv3 or AGPLv3 licenses. Note this excludes many popular licenses such as MIT, LGPL, GPLv2, GPLv2+, GPLv3+, and so on.


IANAL/IANYL, but provided you're happy with making your content available under GPLv3, you should be fine.

You're planning on implementing the Wikipedia-provided pseudocode in other languages, which means you're creating a derivative work (or, as CC refers to it, Adapted Material). Content in Wikipedia may be reused under CC-BY-SA 3.0 or later. The next such later version, CC-BY-SA 4.0, says that

if You Share Adapted Material You produce, the following conditions also apply


The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.

and one such compatible licence is GPLv3. So by passing through CC-BY-SA 4.0 you can get permission to license your derivative under GPLv3, at which point it becomes absolutely standard free software.

  • Great answer, I ended up accepting amons because it contains additional information.
    – Peter
    May 4, 2019 at 7:23
  • @Peter thank you for that! I entirely agree, and upvoted Amon's answer myself, for the same reason :)
    – MadHatter
    May 4, 2019 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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