Skip to main content

Count tokens across any code repository — fast, local, no API calls

Project description

repotoken

Count tokens across any code repository — fast, local, no API calls.

$ repotoken .

scanning /your/project ...

  file                      tokens              lines
  ────────────────────────  ────────         ──────
  src/parser.py               3.1K              140
  src/main.py                 2.8K              120
  src/utils.py                1.2K               55
  tests/test_parser.py         890               40
  README.md                    430               30

  ──────────────────────────────────────────────────
  TOTAL                       8.4K tokens   385 lines
  files                                           5
  skipped (binary)                                3
  ──────────────────────────────────────────────────

Why?

LLMs have context limits — GPT-4o tops out at 128K tokens, most Claude models at 200K. If you're working with AI tooling on a codebase, you need to know how big your repo actually is in token terms — not lines, not bytes, but tokens.

repotoken tells you exactly that, per file and in total, so you can make informed decisions about chunking, batching, or summarisation.

Install

pip install repotoken

Usage

# scan current directory
repotoken .

# scan any repo
repotoken /path/to/any/repo

Notes

  • Uses cl100k_base encoding (GPT-4 / GPT-4o tokenizer) — accurate for most modern LLMs within ~10-15%
  • Detects binaries using null-byte scanning (same method as git) — no hardcoded extension lists
  • Automatically skips .git, node_modules, __pycache__, .venv, and other noise
  • Sorts output by token count so the heaviest files are at the top
  • No API calls, no network requests, runs entirely locally

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

repotoken-0.1.3.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

repotoken-0.1.3-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file repotoken-0.1.3.tar.gz.

File metadata

  • Download URL: repotoken-0.1.3.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for repotoken-0.1.3.tar.gz
Algorithm Hash digest
SHA256 54975c44e09a3cda2d790feb8ee10828b84f847a95e4aa7c13cc2cd5bfdc91b2
MD5 621e748e2ef00c2304cc4a530746a41b
BLAKE2b-256 c195976fd60848263234744551b2e8cec0556f0f5e7b5c25142d3f49f45da753

See more details on using hashes here.

File details

Details for the file repotoken-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: repotoken-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for repotoken-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b42ab9b0c43de1daea08c38ef37ce95ce9b505e38e96ff1e40e9fe7d5c98e83e
MD5 8d0f8dcd3769356c7e2d79dbeb4c0a75
BLAKE2b-256 9cbc35023ca894832d763f2a7e9f15562d43585f2a6a4aafdb258144bcc120ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page