LicenseID - A portable SPDX License ID matcher
Get the SPDX License ID from license text.
A portable license ID matcher with command line interface and Python API.
Used as a license detection engine for Pitloom software bill of materilas generator.
Features
- Hybrid matching strategy:
- Tier 0 (Shortcut): Immediate identification for exact license names and IDs.
- Tier 1 (Recall): Rapid candidate retrieval using SQLite FTS5 (trigram) with query truncation for performance.
- Tier 2 (Precision): Adaptive ranking using RapidFuzz with boosting for canonical matches.
- Tier 3 (Validation): Optional final validation via
tools-javaif available.
- Unix philosophy: Parseable, line-delimited CLI output.
Installation
Install with pipx:
pipx install licenseid
Or using uv:
uv tool install licenseid
Usage
1. Update the license database
Before matching, you need to build the local license index:
licenseid update
Advanced update options:
--version <version>: Download a specific SPDX License List version (e.g.,3.28.0).--force: Force update even if the local database is already at the target version.--no-cache: Bypass the local cache for downloads.
2. Match a license
Identify license text from a file:
licenseid match LICENSE.txt
Or match from a string:
licenseid match --text "Apache License\nVersion 2.0"
The --text argument supports standard escape sequences (e.g., \n, \t, \") which are automatically unescaped before matching.
Common options:
--db <path>: Use a custom database path (global option). Supports SQLite URIs for in-memory databases (e.g.,file:test?mode=memory&cache=shared).--bold: Print only the top license ID (no other info).--diff: Show a word-by-word diff between the input and the best-matching candidate.--json: Output results in JSON format.
The system uses a composite score (Similarity + Coverage + Popularity) to ensure the "tightest" match is preferred (e.g., distinguishing between a license and its supersets).
3. Cache management
licenseid maintains a local cache of remote data to save bandwidth.
licenses.json: Cached for 45 days.popularity.csv: Cached for 75 days.- SPDX data tarballs are versioned and never expire.
To clear the cache manually:
licenseid --clear-cache
4. Output formats
Default (Unix-friendly):
LICENSE_ID=Apache-2.0 SIMILARITY=0.9850 COVERAGE=1.0000
ID only:
licenseid match LICENSE.txt --bold
Example output:
Apache-2.0
JSON:
licenseid match LICENSE.txt --json
Example output:
[
{
"license_id": "Apache-2.0",
"score": 0.985,
"similarity": 0.985,
"coverage": 1.0,
"is_spdx": true,
"is_osi_approved": true
}
]
Diff (visual comparison):
licenseid match LICENSE.txt --diff
Example output:
LICENSE_ID=Apache-2.0 SIMILARITY=0.9980 COVERAGE=0.9975
WORD DIFF:
--- DATABASE
+++ INPUT
@@ -1601,8 +1601,4 @@
language
governing
permissions
-and
-limitations
-under
-the
-license
+se
Python API
You can use licenseid directly in your Python projects:
import json
from licenseid.matcher import AggregatedLicenseMatcher
# Initialize the matcher (uses default database path if not provided)
matcher = AggregatedLicenseMatcher()
# Match license text
results = matcher.match("MIT License")
# Results are returned as a list of dictionaries (JSON-serializable)
print(json.dumps(results, indent=2))
Example JSON output:
[
{
"license_id": "MIT",
"score": 1.01,
"similarity": 1.0,
"coverage": 0.0
}
]
Development
Running tests
Regular test suite:
pytest
Run benchmarks and accuracy tests (expensive):
pytest --run-benchmark
Configuration
SPDX_TOOLS_JAR: Path to thetools-javajar for Tier 3 validation.
License
Apache-2.0
Metadata
Release files for LicenseID 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| licenseid-0.2.2.tar.gz | 32.9 kB | With provenance | Details for licenseid-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| licenseid-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for licenseid-0.2.2-py3-none-any.whl |
Total release size: 55.3 kB
Release files / licenseid-0.2.2.tar.gz
| Download URL | licenseid-0.2.2.tar.gz |
|---|---|
| Size | 32.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
059df9fbfd6fa2eede4b9e5d32cd5874319a4b0e975e25dbe95e44dea0f1b39c
|
|
BLAKE2b-256 checksum How to use checksums |
fd0a53924a99453e433c7b4c2090218ce9593f4ef97e1579fe7c1768468c4bc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.
Transparency logRelease files / licenseid-0.2.2-py3-none-any.whl
| Download URL | licenseid-0.2.2-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a6a27b1f911ff7f50ab79aa27d775043d67ff987469085e64ff47df583adf67a
|
|
BLAKE2b-256 checksum How to use checksums |
e8c9e0271c91cd714c9ead47b3437f242181b64cd258251f458ee5b875ea1338
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.
Transparency logSecurity for LicenseID 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for licenseid-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.