Open Source License Generator · Tutorial
How to add a licence to a GitHub project
6 min readbeginnerUpdated
Your project is public on GitHub, but without a licence nobody may legally reuse it. You will pick a licence, generate the LICENSE file with your name, and mention the licence in the places people and tools look.
What you need
- The License Generator
- A repository you own
Steps
Decide what you want to allow
Open Not sure which to pick? If you are happy for anyone to use your code, even in closed products, keep the first answer. The suggestion is MIT, the most common licence on GitHub.
Generate the file
Load the example or enter your own name and year. The MIT text now starts with your copyright line. Download it: the file is named
LICENSE, without an extension.Add it to the repository root
Put
LICENSEnext to your README and commit it. GitHub shows the licence name in the repository sidebar once it detects the file.git add LICENSE git commit -m "Add MIT licence" git pushDeclare it in your package file
Package managers read the licence from metadata. Use the SPDX identifier shown in the source file header.
"license": "MIT" // package.json license = "MIT" # pyproject.toml ([project] table)Mention it in the README
End your README with a short Licence section that names the licence and links to the file.
Try it yourself
Opens the Open Source License Generator with this tutorial's sample loaded.
Common mistakes
- Copying a licence from another project
- Another project’s LICENSE has their name in it. Generate a fresh one with yours.
- Choosing a licence that conflicts with your dependencies
- If your project includes GPL code, you generally can’t release the combination under MIT. Check your dependencies’ licences first.
Next steps
Go back to the Open Source License Generator, or keep going with one of these:
FAQ
Do I need to update the year every January?
No. The year marks when the work was first published. Many projects use a range such as 2024–2026, but it isn’t required.