tcount
Local token counter for LLM files, directories and stdin via CLI and Go library.
Tested on macOS and Linux
Use it
macOS arm64
brew install lancekrogers/tap/tcount
brew install lancekrogers/tap/tcount
Check that it works
tcount /tmp/myfile.txtThe output should contain “o200k_base”.
First thing to try
cat > /tmp/myfile.txt <<'EOF'
Hello world! This is a test file for token counting.
The quick brown fox jumps over the lazy dog.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
EOF
cat /tmp/myfile.txttcount /tmp/myfile.txtRun tcount <file> to see the token count for a file.
Linux x86_64
install tcount via npm candidate
npm install -g @obedience-corp/tcount
Check that it works
tcount --versionThe output should contain “tcount version 0.7.0”.
First thing to try
cat > myfile.txt <<'EOF'
Hello world. This is a test file for token counting with tcount.
It contains a few sentences to count tokens locally.
EOF
cat > prompt.md <<'EOF'
# Sample prompt
Write a haiku about token counting in LLM workflows.
EOF
cat > document.md <<'EOF'
# Document
This is a sample document for JSON output testing. Token counting should be local and fast.
EOF
mkdir -p src && printf 'Hello from a\n' > src/a.txt && printf 'Second file with more content for counting tokens.\n' > src/b.txt && ls -Rtcount myfile.txtRun tcount <file> to see the token count for a file.
What it does
- Count tokens exactly with OpenAI tokenizersTested
How to use it
- Run
tcount <file>to see the exact o200k_base token count.
- Run
- Get approximate Claude and Gemini token countsTested
How to use it
- Run
tcount --model claude-sonnet-4.5 <file>for an approximate Claude count. - Run
tcount --model gemini-2.5-pro <file>for an approximate Gemini count.
- Run
- See how much of a context window is usedTested
How to use it
- Run
tcount --model gpt-5 <file>. - Read the Context Usage column in the output table.
- Run
- Count tokens across a directory treeTested
How to use it
- Run
tcount -d <directory>to count tokens in all files under it, including subfolders.
- Run
How far pickfit got
macOS arm64
- Installs
- Starts
- 4 of 4 features work
- Works offline
Linux x86_64
- Installs
- Starts
- 4 of 4 features work
- Works offline
Other systems
Windows: the project says it runs there; pickfit hasn’t tried it.
Good for
- Count tokens in a file
- Count tokens across an entire directory tree
- Check context-window usage for a model
- Count piped prompt tokens for scripts
- Output token counts as JSON for scripting
How pickfit tested it
Each run starts from a clean machine and follows the steps above. How pickfit verifies
macOS arm64
Its main function works
- Replayed from scratch
- Works offline
- Checked on 1 Nov 2026
- Version 0.7.0
Linux x86_64
Its main function works
- Replayed from scratch
- Works offline
- Checked on 30 Oct 2026
- Version 0.7.0