If you're looking to apply an open source license to your software, it can be confusing to figure out which steps you should take and in which order.
There are a few different options for where you can display your license, to make sure it's applied effectively. But there are some common practices that most developers follow.
This article will briefly go through types of open source licenses, how to apply a license to your code, and how to reflect the license in your Terms of Use.
Choosing an Open Source License
The first step is to choose an open source license. Some of the most common open source licenses include:
- GNU General Public License (GPL)
- Apache 2.0 License
- MIT License
- Microsoft Public Licenses
- BSD Licenses
- Common Development and Distribution License (CDDL)
Some licenses are what is called "permissive," while others have some restrictions.
The MIT License and Apache 2.0 License are permissive, meaning that they do not put any restrictions on the distribution or use of the code. These are called permissive licenses.
Others like the GNU GPL are more restrictive, and may include terms like requiring a notice stating that the work is released under the GNU GPL, or requiring derivative works to use the same license. Licenses like this are called copyleft licenses.
Deciding which license to use is up to you. Now let's take a look at how to apply a license to your software.
Including a License File in Your Code
Once you've chosen an open source license, you need to make sure that you display it and include it in the right places, so that it covers your software. You should:
- Include it in the root directory of your code
- Add it to source files
To do this, you need to:
- Create a text file or markup file
- Copy the open source license text
- Paste the text of the license into the text file
- Name the file LICENSE (or LICENSE.txt or LICENSE.md)
- Add this text file into the root directory of your repository
You can also add the text file to each source file in your code.
GNU GPL includes instructions for how you should do this. It recommends including the word "Copyright" inside the file with a pointer to where the full license is (e.g. a link to the GNU GPL website).
You can see the instructions from the GNU GPL license below:
GNU GPL also recommends including information on how to contact you by email and paper mail.
Adding a License in Your Repository
Adding a license to your repository makes it easier for others to locate.
GitHub makes it very easy to add a license to your software projects. To add an open source license to your GitHub repository you can do it in a number of ways:
- Add it when you create a new repository
- Add it later to an existing repository
You can see the steps from GitHub in the image below:
After you have created a new file for your repository, when you select "Choose a license template," you can choose a number of pre-set open source license options.
Once you have selected one, GitHub will automatically fill in the license text for you. Then, you only need to press "Review and Submit" and then "Commit changes."
Now that your license text is included in your code, let's take a look at how to reflect this in your Terms of Use.
Add Relevant Clauses to Your Terms of Use
Your Terms of Use will need to reflect the terms of the open source license that you have applied. If your documents conflict, you may run into legal issues or confusion.
Usually, an End User License Agreement (EULA) is incompatible with an open source license, because the EULA would be more restrictive than the open source permissions.
However, if there are end users of your software, it's a good idea to reflect your open source license in your Terms of Use.
Here's one example from OpenAI's Terms of Use for products like ChatGPT and DALL-E:
This brings the user's attention to the fact that open source licenses may apply to parts of the software.
Here's another example from WithSecure, which also lets users know where they can find the copy of the license (in the product user interface):
Note that the clause also explains that the open source license terms might even override some of the Terms of Use.
Summary
Applying an open source license to your code or software doesn't have to be difficult. As long as you've applied it in your code at the root directory and/or in source code files, this is sufficient to make sure your code is covered.
If you are creating software using GitHub, the process is even easier.
Finally, make sure your Terms of Use reflect the terms of the open source license you have applied to your code.
The first step to compliance: A Privacy Policy.
Stay compliant with our agreements, policies, and consent banners — everything you need, all in one place.