Software & OS

MIT vs GPL License: What Each Requires and Which to Choose

The MIT license lets anyone use, change and redistribute your code, including in closed-source products, as long as they keep your copyright notice. The GPL also allows all of that, but anyone who distributes the program or a modified version must release the whole work under the GPL with its source code, so the code stays open downstream.

This article compares what the license texts actually say. It is not legal advice; for a real licensing decision on a product, talk to a lawyer who knows software licensing in your jurisdiction.

MIT vs GPL at a glance

QuestionMITGPL (v2 or v3)
TypePermissiveCopyleft
Use privately or inside a companyYes, no conditionsYes, no conditions as long as you don't distribute it
Sell copies or charge for the productYesYes
Ship in a closed-source productYesNo: the combined work must be GPL
Must provide source code when distributingNoYes, the complete corresponding source
Must keep the copyright noticeYesYes
Explicit patent grantNoGPLv3 yes, GPLv2 no explicit grant
Length of the license text3 short paragraphsGPLv3 has 18 numbered sections (0 to 17)
SPDX identifierMITGPL-2.0-only, GPL-2.0-or-later, GPL-3.0-only, GPL-3.0-or-later

What the MIT license says

The whole license is three paragraphs. The first grants permission "to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies". The second is the only condition:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

The third disclaims all warranties and liability. That's it. Someone can take MIT code, change it, compile it into a paid app and never publish their changes. Their only obligation is to keep your notice somewhere in the copies they ship, which is why apps carry "open source licenses" or "third-party notices" screens.

The word "sublicense" matters: it lets the recipient pass the code on under different terms, including a proprietary license or the GPL, as long as the original notice travels with it.

What the GPL requires

The GPL is built around one idea: if you pass the program on, you pass on the same freedoms. GPLv3 defines two verbs. To "propagate" is to do anything that would need permission under copyright law. To "convey" is propagation "that enables other parties to make or receive copies". The conditions attach to conveying.

  • Running and private use are free of conditions. GPLv3 section 2 "explicitly affirms your unlimited permission to run the unmodified Program" and says you may "make, run and propagate covered works that you do not convey, without conditions". GPLv2 section 0 says activities other than copying, distribution and modification "are not covered by this License". Modifying GPL code for internal use at your company, without giving copies to anyone outside it, does not trigger the source requirement.
  • Selling is allowed. GPLv3 section 4: "You may charge any price or no price for each copy that you convey".
  • Distributing a modified version means GPL for the whole work. GPLv3 section 5(c): "You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy." GPLv2 section 2(b) says the same in older wording.
  • Binaries must come with source. GPLv3 section 6 lets you convey object code only if you also convey "the machine-readable Corresponding Source", which section 1 defines as all the source code needed to generate, install and run the object code. GPLv2 section 3 allows either shipping the source with the binary or a written offer valid for at least three years.

Putting a GPL program next to unrelated programs on the same disk or download is not enough to spread the license. GPLv2 calls this "mere aggregation" and excludes it explicitly.

Why companies care: the copyleft effect

Suppose your desktop app uses an MIT-licensed JSON library and you ship the app as a closed-source installer. You include the library's license text in your notices file and you are done.

Swap that library for a GPL-licensed one that is compiled into your app, and you now distribute a work based on GPL code. Under section 5(c) the whole app must be licensed under the GPL and you must provide its complete source to every customer who receives it. That is not a penalty clause; it is the deal the author chose. If you can't accept it, the honest options are to pick a differently licensed library, buy a commercial license if the author offers one (dual licensing), or not distribute.

The obligation follows distribution. A server-side web app that uses a GPL library but never ships copies to users is not conveying the program, which is the gap the AGPL was written to close.

GPLv2 vs GPLv3 vs AGPL

LicenseKey difference
GPLv2Older text. No explicit patent license. Projects licensed "GPLv2 only", such as the Linux kernel, cannot simply move to v3.
GPLv3Adds an explicit patent license from each contributor (section 11: "a non-exclusive, worldwide, royalty-free patent license") and clearer rules on conveying object code.
AGPLv3GPLv3 plus section 13: a modified version "must prominently offer all users interacting with it remotely through a computer network" its source. This makes network services count.

"Only" versus "or later" matters too. The GPLv3 "How to Apply" notice suggests the wording "either version 3 of the License, or (at your option) any later version". SPDX encodes the two choices as GPL-3.0-only and GPL-3.0-or-later. "Or later" lets a recipient follow a future GPL version; "only" pins the code to the version you chose.

Can you combine MIT and GPL code?

MIT code can go into a GPL project, because MIT permits sublicensing and asks only for the notice to be kept. The Linux kernel is a concrete case: it is "GPL-2.0" only, its licensing rules require individual files under other licenses to be "compatible with the GPL-2.0", and MIT is in its list of preferred licenses. Kernel files often carry a dual-license header such as:

// SPDX-License-Identifier: GPL-2.0 OR MIT

The reverse does not work. You can't take GPL code into an MIT project and ship the result under MIT terms only, because the GPL portion requires the whole distributed work to be GPL.

How to check which license a dependency uses

Package registries record a license field. These commands read it (real output, October 2026):

npm view express license
MIT

pip show python-dotenv
Name: python-dotenv
...
License: BSD-3-Clause

Treat the registry field as a hint and the LICENSE or COPYING file in the source as the authority. Look also for per-file headers such as SPDX-License-Identifier, because one repository can mix licenses. A field that says UNKNOWN, or a repository with no license file, means you have no license to copy or redistribute the code at all, not that it is free to use.

Which one should you choose for your project?

  • Choose MIT if you want the widest adoption with the least friction, including inside proprietary products, and you are fine with companies keeping their changes private.
  • Choose GPLv3 if you want every distributed version of your code, including improvements by others, to stay open source, and you accept that some companies will avoid it for that reason.
  • Choose AGPLv3 if your code is likely to run as a hosted service and you want the copyleft to cover network users too.
  • Consider Apache-2.0 if you want MIT-style permissiveness plus an explicit patent license (its section 3 has each contributor grant "a perpetual, worldwide" patent license).

Whichever you pick, put the full license text in a LICENSE file at the repository root and add the SPDX identifier to your package metadata so tools can read it. If your project builds on a model or dataset rather than code, the questions are different; see open weight vs open source AI.

Frequently asked questions

Can I use GPL code in a commercial product?
Yes. The GPL does not forbid commercial use or charging money; GPLv3 section 4 says you may charge any price or no price for each copy you convey. What it requires is that when you distribute the program, or a work based on it, you license the whole work under the GPL and make the corresponding source code available to the people who receive it.
Can I use MIT-licensed code in a GPL project?
Yes. The MIT license lets anyone use, modify, merge, sublicense and sell the code, with the single condition that the copyright and permission notice are kept. The Linux kernel, which is licensed GPL-2.0 only, lists MIT among the licenses its individual files may use. Keep the original MIT notice in the files you copy.
Can I relicense MIT code under the GPL?
You can include MIT code in a GPL-licensed work and distribute the combination under the GPL, because MIT permits sublicensing. You cannot remove the original MIT copyright and permission notice, and the original code stays available under MIT from its author.
Does using a GPL library over a network count as distribution?
Under the ordinary GPL, letting users interact with software over a network is not conveying a copy, so the source-code obligation is not triggered by that alone. The AGPL closes that gap: its section 13 requires a modified version to offer its source to all users who interact with it remotely over a network.

Sources