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

@cryptoteep/tokencount

v1.0.0

Published

Fast, zero-dependency token & cost estimator for GPT, Claude, Gemini and other LLM prompts. No wasm, no vocab files, <10kb.

Readme

tokencount

npm version npm downloads license

Fast, zero-dependency token and cost estimator for GPT, Claude, Gemini and other LLM prompts. No wasm binary, no downloaded vocab files, install size under 10kb — just a regex-based estimator that lands within a few percent of real tokenizer output for typical English/code prompts.

Works as a CLI (npx tokencount) and as a library you can require in your own code.

Why

Full tokenizers (tiktoken, gpt-tokenizer, @anthropic-ai/tokenizer) ship large wasm binaries or vocabulary tables just to answer "roughly how many tokens is this / what will it cost me?". tokencount skips the vocabulary entirely and gives you a fast approximate answer instead — good enough for budgeting, CI guardrails, and quick sanity checks before you hit an API.

Install

npm install -g @cryptoteep/tokencount
# or just run it once, no install:
npx @cryptoteep/tokencount "some text"

CLI usage

tokencount "Hello, world!"
# 4

echo "some text" | tokencount -m claude-3-5-sonnet

tokencount -f prompt.txt --cost -m gpt-4o --output 500
# {
#   "model": "gpt-4o",
#   "inputTokens": 128,
#   "outputTokens": 500,
#   "inputCost": 0.00032,
#   "outputCost": 0.005,
#   "totalCost": 0.00532
# }

tokencount --list-models

Use it as a pre-commit or CI check to catch prompts that quietly grew too large:

tokencount -f prompts/system.txt | awk '{ if ($1 > 4000) exit 1 }'

Library usage

const { estimateTokens, estimateCost, listModels } = require('@cryptoteep/tokencount');

estimateTokens('Hello, world!'); // 4
estimateTokens('Hello, world!', 'claude-3-5-sonnet'); // model-aware estimate

estimateCost('Explain quantum computing.', 'gpt-4o-mini', { outputTokens: 300 });
// { model, inputTokens, outputTokens, inputCost, outputCost, totalCost }

listModels(); // ['gpt-4o', 'gpt-4o-mini', 'claude-3-5-sonnet', ...]

TypeScript types are bundled (index.d.ts), no @types package needed.

Accuracy

tokencount uses the same GPT-2-style pre-tokenization regex real BPE tokenizers start from (splitting on words, numbers, punctuation and whitespace runs), then applies a small per-model-family correction factor. It will not match tiktoken/gpt-tokenizer exactly — real BPE merges push counts a bit lower for common words — but it's typically within a few percent for natural-language and code prompts, at a fraction of the install size and with no vocabulary file to keep in sync.

If you need exact counts, use the vendor tokenizer. If you need a fast estimate for budgeting or CI, this is for that.

Pricing data

The bundled price table is a small, illustrative snapshot and will go stale — LLM pricing changes often. For an up-to-date catalog across 100+ models, see the companion package llm-prices (npx llm-prices).

License

MIT © Cryptoteep