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

codeworth

v2.1.0

Published

Estimate what a codebase would have cost to build traditionally, using COCOMO over accurately counted source lines.

Downloads

395

Readme

CodeWorth

Estimate what a codebase would have cost to build traditionally — using a real cost model (Basic COCOMO) over accurately counted source lines, not a flat dollars-per-line guess.

npm install -g codeworth

v2 is a rewrite. The number it produces is different from v1 on purpose: v1 over-counted lines (it counted blank lines, comments, and a phantom trailing line per file) and then multiplied by a flat rate. See the CHANGELOG.

Quick start

# Scan the current directory and estimate build cost (COCOMO, organic mode)
codeworth

# Estimate from a known SLOC count
codeworth 26024

# Legacy flat-rate behavior (SLOC × rate)
codeworth 26024 --simple --rate 10.77

# Machine-readable output for CI
codeworth --json > report.json

What it does

  1. Counts source lines accurately. A comment- and string-aware classifier splits every file into code / comment / blank lines across ~40 languages, so URLs like http://… aren't mistaken for comments and blank lines don't inflate the total. It skips binaries, minified/generated files, and (by default) anything your .gitignore files exclude (root and nested).
  2. Separates code from data/docs. JSON, YAML, Markdown, etc. are reported but don't drive the cost estimate unless you pass --include-all.
  3. Estimates cost with COCOMO. Effort grows non-linearly with size, so the estimate reports person-months, schedule, team size, and every assumption — not an opaque per-line figure.

The cost model

Default is Basic COCOMO (Boehm, 1981), the model behind David A. Wheeler's SLOCCount:

Effort (person-months) = a × KSLOC^b
Schedule (months)      = c × Effort^d
Cost                   = Effort × (annualSalary / 12 × overhead)

| Mode | a | b | When | |------|---|---|------| | organic (default) | 2.4 | 1.05 | Small team, well-understood product | | semi-detached | 3.0 | 1.12 | Medium size/complexity | | embedded | 3.6 | 1.20 | Tight constraints, high complexity |

Tune it:

codeworth --mode semi-detached --salary 130000 --overhead 2.0

All assumptions are printed with the result so the estimate is auditable.

Options

| Flag | Description | |------|-------------| | --mode <name> | COCOMO mode: organic | semi-detached | embedded | | --salary <n> | Annual developer salary (default 110000) | | --overhead <n> | Overhead multiplier (default 2.4) | | --simple | Legacy flat model: cost = SLOC × rate | | --rate <n> | Per-line rate for --simple (default 10.77) | | --path <dir> | Directory to scan (default: cwd) | | --ignore <glob> | Exclude paths matching a gitignore-style glob (repeatable) | | --no-gitignore | Do not honor .gitignore (root + nested) | | --include-generated | Include minified/generated files | | --include-all | Count data/docs languages toward cost too | | --json | Machine-readable JSON output | | --version, --help | — |

Example output

===================================================
  CodeWorth — estimated cost to build traditionally
===================================================

  Language     Files       Code    Comment     Blank
  ---------------------------------------------------
  TypeScript      42      6,120        410       880
  CSS              8        940         30       120
  JSON             3         60          0         2 *

  * = not counted toward cost (data/docs). See --include-all.

  Totals
  ------
  Billable SLOC      : 7,060
  ...

  Estimate
  --------
  Model              : Basic COCOMO — Organic (small/simple team & product)
  Effort             : 18.7 person-months (1.6 person-years)
  ...
  ---------------------------------------------------
  ESTIMATED COST     : $412,300
  ---------------------------------------------------

Accuracy & limitations

  • Line classification is heuristic and line-oriented (the approach used by basic counters like SLOCCount). Comment markers inside multi-line string/template literals may be misclassified in rare cases.
  • Both root and nested .gitignore files are honored (deeper files override shallower ones). Use --ignore <glob> for anything git doesn't already ignore.
  • Unknown file types are excluded from the cost estimate.
  • COCOMO estimates build effort/cost, which is not the same as market value.

Programmatic use

import { scanDirectory } from 'codeworth/counter';
import { cocomo } from 'codeworth/cost';

const { totals } = scanDirectory(process.cwd());
console.log(cocomo(totals.codeSloc, { mode: 'organic' }));

License

MIT