Skip to main content

LicenseID - A portable SPDX licence identification tool

PyPI - Version GitHub License OpenSSF Best Practices OpenSSF Scorecard DOI

Get the SPDX License ID from licence text.

A portable SPDX licence identification tool with a command line interface and a Python API. No database daemon or server needed.

Used as a licence detection engine for Pitloom software bill of materials generator.

Features

  • Finds the licence in a file, a licence text or a source file's SPDX-License-Identifier tag.
  • Reads a declared value (a license field, a trove classifier) as an SPDX expression, with each step taken, or refuses: it never guesses.
  • Normalises expressions: (MIT OR MIT) and Apache-2.0 -> Apache-2.0 AND MIT; deprecated IDs: GPL-2.0+ -> GPL-2.0-or-later.
  • Reads a licence URL (https://www.apache.org/licenses/LICENSE-2.0 -> Apache-2.0), loose IDs (Apache2, GPLv3), a licence's own title (CC0 1.0 Universal), the BSD aliases (New BSD, BSD-3), prose forms (BSD 3-Clause License) and trove classifiers.
  • Prints parseable, line-delimited output.

Installation

pipx install licenseid

Or with uv: uv tool install licenseid. Under a multibyte locale that is not UTF-8, set PYTHONUTF8=1 first; see installation.

Quick start

Build the local licence index once:

licenseid update

Then ask a question. detect finds the licence in a file, an ID or a text; resolve reads a declared value and needs no database. Each prints the SPDX expression alone, best first (--top 1 keeps one), or an empty line and exit code 1 when there is no answer:

licenseid detect --top 1 LICENSE.txt        # Apache-2.0
licenseid detect --top 1 MIT                # MIT
echo "MIT License..." | licenseid detect    # a text from standard input
licenseid resolve "GPLv2 or later"          # GPL-2.0-or-later

Add -v for the detail behind the answer (score, steps, reason), or --json for one JSON object per result:

$ licenseid resolve -v "GPLv2+ or MIT"
EXPRESSION=GPL-2.0-or-later OR MIT	CATEGORY=version_spelling	TRUST=resolver_rule
STEP=separator	FROM=GPLv2	TO=GPL-2.0
STEP=version_spelling	FROM=GPLv2	TO=GPL-2.0
STEP=operator_case	FROM=GPL-2.0-or-later or MIT	TO=GPL-2.0-or-later OR MIT
STEP=plus_to_or_later	FROM=GPLv2+	TO=GPL-2.0-or-later

Licence checks in scripts

is-spdx, is-osi and is-fsf exit 0 for true and 1 for false:

licenseid is-osi MIT >/dev/null && echo "OSI-approved"

Python

from licenseid import detect, resolve

detect(file_path="LICENSE")[0]["expression"]  # "Apache-2.0"
resolve("GPLv2 or later")["expression"]       # "GPL-2.0-or-later"

Use detect() to scan files and resolve() to record what a package declares, as an SBOM tool does.

Documentation

  • Installation: install, and the non-UTF-8 locale note.
  • Command line: every command, option, input kind, exit code and the is-* predicates.
  • Output formats: the text record, JSON Lines, fields, escaping, reading the output with awk and jq, and error lines.
  • Python API: detect(), LicenseDetector, the predicates, results, errors and warnings.
  • Declared values: what resolve() reads and returns, its categories, trust and reasons for a refusal.
  • How it works: ID normalisation, expressions and the matching tiers.
  • Development: running the tests.

License

Apache-2.0

Citation

If you use this software, please cite it as follows:

Suriyawongkul, A. (2026). LicenseID - A portable SPDX licence identification tool (Version 0.8.4) [Computer software]. https://doi.org/10.5281/zenodo.19881009

BibTeX:

@software{Suriyawongkul_LicenseID_-_A_2026,
    author = {Suriyawongkul, Arthit},
    doi = {10.5281/zenodo.19881009},
    license = {Apache-2.0},
    month = nov,
    title = {{LicenseID - A portable SPDX licence identification tool}},
    url = {https://github.com/bact/licenseid.git},
    version = {0.8.4},
    year = {2026}
}

Metadata

Release files for LicenseID 0.8.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LicenseID 0.8.4
File Size Uploaded Provenance Actions
licenseid-0.8.4.tar.gz 1.3 MB With provenance Details for licenseid-0.8.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for LicenseID 0.8.4
File Interpreter ABI Platform Actions
licenseid-0.8.4-py3-none-any.whl Python 3 none any Details for licenseid-0.8.4-py3-none-any.whl

Total release size: 2.5 MB

Release files / licenseid-0.8.4.tar.gz

Download URL licenseid-0.8.4.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
15447cb28223607d183b120b39a07608bd8d044a3b4a6d3e01f975fc9d58d7bc
BLAKE2b-256 checksum
How to use checksums
40a6929ec9bb91050a8c265f9997a08c97be630d1c34e10aa84d6e580d8f033e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Release files / licenseid-0.8.4-py3-none-any.whl

Download URL licenseid-0.8.4-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6781e29fa1a0906a301f664ac1efffefbd689d8c4d4a8dcf6c602b060c8e0e51
BLAKE2b-256 checksum
How to use checksums
662f0993cba4b9ac9fe76d266d1adb020172e601daef089bdec15681cd17b0a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Security for LicenseID 0.8.4

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.

Select from 2 files

Attestation for licenseid-0.8.4.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 Nov 9, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.8.4 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page