Safeguard
Developer Tools•

How do you normalize messy license names to SPDX identifiers?

Free text names like Apache License, Version 2.0 must map to SPDX ids before a policy can act. A mapping method, edge cases, and what to leave as unknown.

Safeguard Security Team
3 min read

Normalize messy license names by mapping each string to an SPDX identifier through a reviewed alias table, parsing expressions with AND, OR and WITH, and sending anything that does not match cleanly to an unknown bucket. Never guess. A wrong mapping turns a review item into a false approval.

Why it is needed

Ecosystems differ. Maven's name field is free text and the reference only recommends SPDX. Older Python packages used free text and classifiers. npm accepts SPDX expressions and a pointer to a custom file. A policy engine needs one vocabulary, and SPDX is the common one. The SPDX License List, currently at version 3.29.0 dated 16 September 2026, gives each license a stable short identifier and has a separate list of exceptions.

A mapping method

  1. Collect every distinct license string in your inventory, with a count.
  2. Build an alias table: for example several spellings of the Apache license map to Apache-2.0.
  3. Have a person review the table once. Review the long tail by frequency.
  4. Parse expressions as expressions. Split on AND, OR and WITH, and map each part.
  5. Keep deprecated identifiers mapped to their current form, since deprecated ones remain valid but should no longer be used.
  6. Mark every mapped result with its source string, so reviewers can see the original.
InputOutputConfidence
MITMITHigh, already an id
Apache Software License 2.0Apache-2.0High after review
GPLUnknownLow, version is missing
BSDUnknownLow, which BSD?
See license fileRead the fileManual

Cases that must stay unknown

A bare GPL could be version 2 or 3, only or or later, and the difference matters. A bare BSD could be two, three or four clauses. A string that names a license plus an extra sentence is not the standard license. See GPL only versus or later identifiers.

Keep the table alive

Review new strings weekly. Re-run normalization when the SPDX list updates. Store overrides with a reason, so one decision serves every project.

Try it yourself

Click through it at your own pace, or open it full screen.

Scan the component list for license values and judge which ones would map cleanly.

Safeguard offers SBOM and dependency scanning, plus a free scan.

Quick check

Can I map a bare GPL to GPL-3.0-only?

No. Version and the only or later choice are unknown, so keep it unknown until someone checks.

Should deprecated identifiers be rejected?

No. SPDX says they remain valid. Map them to the current identifier when you can.

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.