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      385
  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.2.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.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: repotoken-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7b2701552aa6eac44793a6c144037c8dc9bb7aec3e606bf0cf220a0750e1e1e8
MD5 d4beb16ef12b98b41346434dacc8abe3
BLAKE2b-256 9ebd0e9280b62aecf3289ebb19b3ab7386a10d25a304b2c177ff7706ce1613cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: repotoken-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8758167cfd08d0fae4493638f6610668d9b9709dd5e79a00cb9ee50bf43938
MD5 5a3118074d8ccb3941dc5e9ff3e24908
BLAKE2b-256 efc483c730cb8015a0ef3720171103885386b785272856e8144e363aaffc8fd1

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