MIT vs Apache 2.0 vs GPL: How to Choose an Open Source License

Compare MIT, Apache 2.0, GPL, BSD, MPL and the Unlicense in plain English, learn what each one asks of users, and add a LICENSE file to your repository.

Updated September 29, 2026 7 min read

Use the free Open Source License GeneratorCreate MIT, Apache, GPL, BSD, ISC, MPL or Unlicense text with your name

You have written a small library, a command-line utility or a website template, and you are about to make the repository public. Somewhere in the checklist is "add a license", and suddenly you are reading about copyleft, patent grants and NOTICE files. Picking one at random is tempting, but the license decides whether a company can build your code into a paid product, whether improvements must come back to the community, and what happens if someone asserts a patent.

This guide explains the main open source licenses in plain English, compares them side by side, and walks through adding the right text to your project. It is a practical overview, not legal advice. If your employer, a client contract or a large amount of money is involved, have a lawyer read the actual license texts before you decide.

Why a license matters at all

Copyright applies automatically when you write code. Without a license, the default in most countries is "all rights reserved": other people may be able to look at your repository, but they have no clear permission to copy, modify or redistribute it. Publishing code on a public site does not by itself make it open source.

An open source license is a standard, pre-written grant of permission. Instead of negotiating with every user, you attach one well-known text and everyone knows the rules. Widely recognised licenses are also far easier for companies to evaluate than custom terms.

The two families: permissive and copyleft

Almost every popular license falls into one of two groups.

Permissive licenses (MIT, BSD, ISC, Apache 2.0) let anyone use, modify and redistribute your code, including inside closed-source commercial products. The main obligation is to keep your copyright and license notice. You get maximum adoption, and you accept that someone may ship a proprietary fork without sharing their changes.

Copyleft licenses (GPL, and in a lighter form MPL) also allow use and modification, but when someone distributes a modified version, they must make the source available under the same license. This keeps derived work open, at the cost of making some companies cautious about adopting your code.

The main licenses compared

License Commercial use Explicit patent grant Must share changes Main condition
MIT Yes No No Keep copyright and license notice
BSD 2-Clause Yes No No Keep notice in source and binary docs
BSD 3-Clause Yes No No As 2-Clause, plus no use of your name to endorse
ISC Yes No No Keep notice (MIT-like, shorter wording)
Apache 2.0 Yes Yes No Keep notices, mark changed files, keep NOTICE file
MPL 2.0 Yes Yes Only modified MPL files File-level copyleft
GPL 3.0 Yes Yes Yes, when distributing Whole program under GPL
Unlicense Yes No No None (public domain dedication)

MIT, ISC and BSD

These are short and very common. ISC is close to MIT in effect, with simpler wording. BSD 3-Clause adds one clause: nobody may use your name to promote a derived product without permission. None of them mention patents explicitly.

Apache 2.0

Apache is permissive like MIT but longer, because it spells out more. Contributors grant users a patent license for their contributions, and that patent license ends for anyone who sues claiming the software infringes a patent. Modified files must carry a notice saying they were changed, and if the project ships a NOTICE file, redistributors must keep it. Many companies prefer Apache 2.0 for exactly this clarity.

GPL 3.0

The GPL is the classic strong copyleft license. If you distribute a program that includes GPL code, the whole program must be offered under the GPL with its source. Using GPL software privately, or running it on your own server, does not by itself count as distribution; the separate AGPL was written to cover software offered over a network. Note that the standard GPL notice says "version 3, or (at your option) any later version", which corresponds to the SPDX identifier GPL-3.0-or-later. If you want to exclude later versions, use GPL-3.0-only and edit the notice accordingly.

MPL 2.0

The Mozilla Public License is a middle ground. Copyleft applies per file: if someone changes an MPL-licensed file and distributes it, that file's source must stay open, but it can be combined with proprietary files in a larger product.

The Unlicense

The Unlicense dedicates your work to the public domain, with a permissive fallback for places where that dedication is not recognised. Some organisations avoid public-domain dedications because the legal effect differs between countries, so MIT is often the safer "do anything you like" option.

Quick decision guide

  • You want the widest possible adoption and don't mind closed forks: MIT (or ISC/BSD).
  • You want permissive terms plus explicit patent protection: Apache 2.0.
  • You want every distributed improvement to stay open: GPL 3.0.
  • You want changes to your files to stay open, but allow use in proprietary products: MPL 2.0.
  • You are contributing to an existing ecosystem: match what similar projects use, because mixing licenses can create compatibility problems. For example, GPL code cannot be pulled into an MIT project without the combined work falling under the GPL.

Generate your LICENSE file

Our License Generator fills in the official wording with your details and runs in your browser.

  1. Open the License Generator and click the license you want in the grid (MIT, Apache 2.0, GPL v3.0, BSD 2-Clause, BSD 3-Clause, ISC, MPL 2.0 or the Unlicense). A short summary appears under the fields.
  2. Type the Copyright holder: your name, or your company's legal name if the code belongs to your employer.
  3. Check the Year(s) field. It defaults to the current year; for an older project you can use a range such as 2021-2026.
  4. For GPL v3.0, fill in Program name and one-line description, which goes at the top of the notice.
  5. Copy or download the output. For MIT, BSD, ISC and the Unlicense you get the full license text. For Apache 2.0, GPL and MPL, which are long, the tool gives you the official short notice to place at the top of your source files or in your README, plus a link to the full official text.
  6. Save the full text as a file named LICENSE (no extension is the usual convention) in the root of your repository.

Declare the license everywhere it matters

A LICENSE file is the foundation, but package managers and scanners also look for machine-readable identifiers. Use the SPDX short identifier in your manifest, and validate the edited file with a JSON Formatter if your editor doesn't:

{
  "name": "invoice-parser",
  "version": "1.0.0",
  "license": "MIT"
}

Many projects also add a one-line header to each source file, which survives when files are copied out of the repository:

// SPDX-License-Identifier: Apache-2.0

Mention the license in your README as well. If you are also setting up a new repository, the .gitignore Generator and Code Formatter help with the rest of the housekeeping.

Common mistakes

Leaving the placeholder text in

[year] and [fullname] left in a LICENSE file look careless and can create doubt about who the copyright holder is. Always fill both in.

Forgetting third-party notices

If you bundle other open source code, keep their license texts too. Permissive licenses still require the notice to travel with the code.

Frequently asked questions

What happens if my public repository has no license?

By default, copyright law reserves all rights to you. Others can view the code where it is hosted, but they have no clear permission to use, copy or modify it, so most companies will not touch it.

Can I use MIT-licensed code in a commercial product?

Yes. MIT allows commercial use, modification and closed-source distribution, as long as you keep the original copyright and license notice with the code.

Is Apache 2.0 better than MIT?

Neither is better in general. Apache 2.0 adds an explicit patent grant and clearer rules for contributions, while MIT is shorter and simpler. Choose Apache if patent clarity matters to you or your users.

Where should the LICENSE file go?

Put it in the root of the repository, named LICENSE or LICENSE.txt. Hosting platforms and package tools look there to detect and display the license.

Can I change my project's license later?

You can relicense code you wrote alone, but versions already released stay available under the old license. Code contributed by others usually needs their permission to relicense.

Try it now: Open Source License Generator

Loading tool…