How to Choose an Open Source License and Generate a LICENSE File
Understand permissive, weak and strong copyleft licenses, compare MIT, Apache-2.0, GPL and MPL, and generate a LICENSE file with SPDX headers.

How to Choose an Open Source License and Generate a LICENSE File
Publishing code on GitHub does not make it open source. Without a licence, copyright law treats the work as "all rights reserved": people can read it, but they have no permission to copy, modify or redistribute it. Choosing a licence is the step that grants those permissions, and it also decides what others owe you in return. This guide explains the main licence families, how to compare them, and how to generate the files with a free picker.
This article is general information, not legal advice. If a decision has commercial or legal consequences, talk to a lawyer who knows your situation.
The three families
Open-source licences fall into three broad groups.
Permissive licences such as MIT, BSD, ISC, Apache-2.0 and the Boost Software License allow almost any use, including inside closed-source products, provided the copyright and licence notice are kept. Apache-2.0 adds an explicit patent grant and requires noting significant changes.
Weak copyleft licences sit in the middle. MPL-2.0 works per file: if you change an MPL-licensed file and distribute it, you must share that file's source, but you can combine it with code under other terms. LGPL-3.0 applies a similar idea at the level of a library.
Strong copyleft licences, GPL-2.0 and GPL-3.0, require that a distributed work based on the code is released under the same licence with source available. AGPL-3.0 goes further and treats offering the software to users over a network like distribution.
There are also public-domain style dedications that waive as many rights as the law allows.
Questions that narrow the choice
A handful of questions decide most cases:
- Should people who distribute modified versions have to use the same licence?
- Should that obligation also apply to software run as a network service?
- Do you want an explicit patent grant?
- Would file-level copyleft be enough?
- Do you want to give up copyright entirely?
There is no universally best answer. Permissive licences maximise adoption; copyleft keeps derivative work open.
Picking and generating with the tool
Open the License Picker and Generator. In Help me choose, set each question to yes, no or Don't mind. Questions left on Don't mind are ignored, and cards for the matching licences appear with a one-line description each.
The Compare grid lists licences as rows and terms as columns: commercial use, modification, distribution, private use, patent grant, notice requirements, stating changes, source disclosure, network use, same-licence requirements, liability and warranty disclaimers, and trademark rights. A tick means the licence grants a permission, a dot marks a condition you must meet, and a stop sign marks something it does not give.
Press Use on a card, or pick from the License menu, then enter the year, copyright holder and optionally the project name. The LICENSE file tab fills the official text and shows the matching license field for package.json; GNU licences are often saved as COPYING. The File headers tab writes two lines for the top of each source file, SPDX-FileCopyrightText and SPDX-License-Identifier, in the comment syntax of the extension you type. The identifiers come from the SPDX License List. For GPL-family licences the tool writes the -or-later form; change it to -only if you do not want later versions to apply.
Worked example
You maintain a small TypeScript library. You want companies to use it freely and you want contributors' patent rights covered, but you do not want copyleft. Set the same-licence question to no and the patent grant question to yes. Apache-2.0 remains among the matches. After entering your name and year, the LICENSE tab produces the full Apache text, and the header for .ts files reads:
// SPDX-FileCopyrightText: 2026 Your Name
// SPDX-License-Identifier: Apache-2.0
Tips and common mistakes
- Check the licences of your dependencies before choosing; a GPL dependency affects what you can ship.
- Put the licence file in the repository root so platforms detect it.
- Do not edit the licence text itself. Custom wording creates a new, unknown licence.
- If others have contributed, relicensing their code needs their agreement.
- Copies released under an old licence stay under it even if you change licence later.
Limits
The tool explains licence terms in general and fills in standard texts; it is not legal advice and does not replace a lawyer. It does not analyse whether your dependencies' licences are compatible with your choice, and it cannot verify that you own the rights to license the code. It covers a set of widely used licences, not every licence on the SPDX list.



