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.4.tar.gz (3.3 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.4-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: repotoken-0.1.4.tar.gz
  • Upload date:
  • Size: 3.3 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.4.tar.gz
Algorithm Hash digest
SHA256 6363134a7c192260cd0a1a8b515a7a84d0b25fedf9bb8df77845483594e9d468
MD5 47554789f5f35b19531174850c173274
BLAKE2b-256 296c1eabde897c9bafda69af16ebfbca4277d3e0e24427455fffa91f4f0d1771

See more details on using hashes here.

File details

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

File metadata

  • Download URL: repotoken-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 3.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 09bdc9cc360af788843cbc139438adf3bfd89de69eec3d5e95a1c5a1796e7642
MD5 fc3cd4864b9a32561c543e3e49ac977f
BLAKE2b-256 299521728fe551d9431d4c5cabaaadb10a0dc9cad6f71b7a32f508adacce164a

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