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.
  • Says when the input does not state a licence's variant (GPL-2.0: -only or -or-later?), and lets you choose one with --variant.
  • 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, from a wheel, 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 "Licensed under the MIT License" | licenseid detect    # MIT, from stdin
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.
  • Resolve flow: the readers resolve() applies to a value, in order.
  • Canonical form: how an expression is put in canonical form, rule by rule.
  • Lists: the lists resolve() reads (BSD names, titles, classifier names, licence URLs) and its named rules, with their sources.
  • 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.9.0) [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.9.0},
    year = {2026}
}

Metadata

Release files for LicenseID 0.9.0

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.9.0
File Size Uploaded Provenance Actions
licenseid-0.9.0.tar.gz 1.3 MB With provenance Details for licenseid-0.9.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.7 MB

Release files / licenseid-0.9.0.tar.gz

Download URL licenseid-0.9.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
e5cff12c209c69e6ee820e0e8a00316f58227776d857aa7311c42aebe88378c5
BLAKE2b-256 checksum
How to use checksums
7559d6bfad4437e751487f1d2512ea517f89bab76e0d2bcac04d73e831e17dc2
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 19, 2026.

Transparency log

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

Download URL licenseid-0.9.0-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
15fc26c4b1bd9f3244fe5f2231004c19aee065e86586f3fecf7835c7ddcfac1c
BLAKE2b-256 checksum
How to use checksums
b565c99e40db7c4e10853381e4a48a75401a3120c7a1cca899b1870127defc45
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 19, 2026.

Transparency log

Security for LicenseID 0.9.0

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.9.0.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 19, 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.9.0 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