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

codemass

v0.2.1

Published

Weigh your code in tokens - calculate AI API costs for your codebase

Downloads

122

Readme

codemass

logo

⚖️ Weigh your code in tokens - calculate AI API costs for your codebase before feeding it to LLMs.

Features

  • 🔢 Universal token counting - Counts tokens in ALL text files
  • 💰 Multi-model cost estimation - Support for 10+ LLM models with current pricing
  • 🚫 Smart exclusions - Respects .gitignore and skips binary files
  • 📊 Detailed breakdown - See token distribution by file type
  • 🎯 Flexible filtering - Exclude specific file types or patterns

Installation

npx codemass

Or install globally:

npm install -g codemass

Usage

# Analyze current directory
npx codemass

# Analyze specific directory
npx codemass ./src

# Choose pricing model (default: sonnet-4)
npx codemass --model gpt-5

# Exclude file types
npx codemass --no-json --no-yaml
npx codemass --exclude .test.js,.spec.ts

# List available models
npx codemass --list-models

Options

  • --model <id> - Choose LLM model for pricing (default: sonnet-4)
  • --list-models - Show all available models with pricing
  • --exclude <exts> - Exclude specific extensions (comma-separated)
  • --no-json - Exclude JSON files
  • --no-markdown - Exclude Markdown files
  • --no-yaml - Exclude YAML files

Supported Models

| Model | Input $/1M | Output $/1M | | ----------------------------- | ---------- | ----------- | | Claude Opus 4 | $15.00 | $75.00 | | Claude Sonnet 4 (default) | $3.00 | $15.00 | | Gemini 2.5 Pro | $1.25 | $10.00 | | GPT-5 | $1.25 | $10.00 | | Gemini 2.5 Flash | $0.30 | $2.50 | | GPT-5 mini | $0.25 | $2.00 | | Gemini 2.5 Flash-Lite | $0.10 | $0.40 | | GPT-5 nano | $0.05 | $0.40 |

How It Works

  1. Scans all text files in your project (respecting .gitignore)
  2. Counts tokens using OpenAI's o200k_base tokenizer
  3. Calculates costs based on selected model pricing
  4. Shows breakdown by file type and largest files

Example Output

⚖️  Weighing: /path/to/project

================================================================================
CODEMASS ANALYSIS
================================================================================
Total Files: 142
Total Tokens: 285,431 (o200k_base tokenizer)
Total Size: 1.23 MB
Average Tokens/File: 2,010

BY FILE TYPE:
----------------------------------------
.ts        156,234 tokens (54.7%) - 89 files
.tsx        98,456 tokens (34.5%) - 42 files
.css        30,741 tokens (10.8%) - 11 files

TOP 20 FILES BY TOKEN COUNT:
--------------------------------------------------------------------------------
    Tokens        Size    Path
--------------------------------------------------------------------------------
     5,234      23.4 KB    src/components/Dashboard.tsx
     4,892      21.2 KB    src/utils/parser.ts
     ...

================================================================================
COST ESTIMATION (Claude Sonnet 4):
Input:  ~$0.86 ($3/1M tokens)
Output: ~$4.28 ($15/1M tokens)
Total:  ~$5.14 (if output = input size)
================================================================================

Notes

  • Token counts use OpenAI's o200k_base tokenizer
  • For non-OpenAI models, token counts are estimates and may vary slightly
  • Binary files are automatically detected and skipped
  • Always respects .gitignore patterns

License

MIT