npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ferrow/license-detector

v1.0.0

Published

Detect open-source licenses from raw file text using normalized fingerprint matching against a built-in corpus of 12 common licenses. Zero runtime dependencies.

Readme

license-detector

CI

Detect open-source licenses from raw file text via normalized fingerprint matching against a built-in corpus of 12 common licenses. Strict TypeScript, zero runtime dependencies.

Why

Scanning a dependency tree or a batch of vendored files for license text usually just needs a quick, dependency-free heuristic — not a full legal-grade classifier. This library normalizes text (lowercase, strip copyright lines, collapse whitespace) and scores it against distinctive phrase sets for each license family, so it's forgiving of copyright-holder differences but honest about confidence when the text has been reworded or is ambiguous.

This is a text heuristic, not legal advice. Always have a human (or counsel) confirm licensing decisions that matter.

Quickstart

import { detectLicense, parseSpdxExpression } from "license-detector";

const results = detectLicense(fileText);
// [{ spdxId: "MIT", name: "MIT License", confidence: 1, matchedPhrases: [...] }]

const ast = parseSpdxExpression("(MIT OR Apache-2.0) AND GPL-2.0 WITH Classpath-exception-2.0");

API

detectLicense(text, options?): DetectionResult[]

Scores text against the 12-license corpus, sorted by confidence descending. options.minConfidence (default 0.15) filters low-confidence noise; options.limit (default 3) caps results.

detectLicenseBatch(files, options?): BatchResult[]

Runs detectLicense over { path, text }[].

normalize(text): string

The normalization step used internally — lowercase, copyright-line stripping, whitespace collapse. Exposed for callers who want to inspect or reuse it.

listKnownLicenses(): string[]

The 12 SPDX ids in the corpus: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, GPL-2.0, GPL-3.0, LGPL-3.0, MPL-2.0, Unlicense, CC0-1.0, WTFPL.

parseSpdxExpression(expression): SpdxNode

Parses a simplified SPDX license expression (AND / OR / WITH, parenthesized grouping) into an AST.

collectLicenseIds(node): string[]

Flattens all license ids referenced in a parsed SPDX expression.

Limits

  • 12 licenses only — anything outside that corpus scores below minConfidence and is omitted.
  • Phrase-based matching is sensitive to significant rewording of license text (by design — see the demo, where a reworded MIT text drops from confidence 1 to 0.5).
  • Confidence is a fraction of matched distinctive phrases, not a probability or legal certainty.

Part of the ferrow-toolkit collection · Sponsored by Ferrow