Safeguard
Compliance•

How do you read an SPDX license expression like MIT OR Apache-2.0?

How to read SPDX license expressions: what OR, AND and WITH mean for a library you want to adopt, and what to ask your legal contact before using it.

Safeguard Security Team
4 min read

In an SPDX license expression, OR means you may choose one of the licenses, AND means you must satisfy all of them, and WITH adds a named exception to a license. So MIT OR Apache-2.0 lets you pick either. Read the expression before adopting a library, and ask legal about anything unclear.

What SPDX expressions are

SPDX is a standard way to name licenses with short identifiers. The SPDX specification defines license expressions for cases where a single identifier is not enough, for example when software is offered under a choice of licenses, or when a program combines files under different licenses. The identifiers come from the SPDX License List, which gives each license a standard short identifier, full name and permanent URL.

Many package registries carry a license field in this format, which makes it machine readable.

The operators

OperatorMeaningExampleWhat you do
ORLicensee choosesGPL-2.0-only OR BSD-3-ClausePick one and follow its terms
ANDAll applyLGPL-2.1-only AND BSD-3-ClauseSatisfy both sets of terms
WITHLicense plus exceptionA license WITH a named exceptionRead the exception text; it modifies the license
+That version or laterA license identifier followed by a plus signYou may use a later version too
ParenthesesGrouping(A OR B) AND CEvaluate the inside first

The OR and AND examples above come straight from the SPDX specification. Note that AND often appears when one package bundles several components, so the strictest part tends to drive your obligations.

Steps to handle an expression

  1. Copy the license expression from the package metadata or repository.
  2. Replace each identifier with its entry on the SPDX License List and read the text, or have counsel read it.
  3. For OR, decide which option you will rely on and write it down. Choosing is your right as licensee, so record the choice for later audits.
  4. For AND, list the combined obligations, such as notices, source offers or attribution.
  5. For WITH, read the exception. It may relax a restriction, but only in the way it describes.
  6. Check how you distribute: a library used inside a hosted service and one shipped inside a downloadable app can raise different questions. Ask legal when in doubt.

For the broader picture, see license compatibility when combining open source components and copyleft versus permissive licenses.

Pitfalls

  • Free text instead of an identifier. If the field says "see LICENSE", open the file. Treat unclear fields as unknown until you read them.
  • Metadata that disagrees with the repository. Trust the license text, and flag the mismatch.
  • Per-file licenses. Some projects mix licenses across files. The REUSE initiative, started by the Free Software Foundation Europe, recommends stating the license of each file so humans and tools can read it.

This post is general information, not legal advice.

Where Safeguard fits

Safeguard's SBOM and dependency scanning list components with their license data so you can review them in one place, and policies can gate changes in pull requests. Try the free scan at gold.safeguard.sh/scan.

Quick check

If a library is MIT OR Apache-2.0, which one applies to me?

Whichever you choose. Record your choice and follow that license's conditions, such as keeping the notice.

Does WITH make a license weaker or stronger?

It modifies the license in the way the named exception states. Read the exception text before relying on it.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.