TokenCount
A real text and token counter for the terminal. Count words, lines, characters, and sentences. Estimate LLM token usage with cost projections. Analyze word frequency and compare files side by side.
Commands
| Command |
Description |
tokencount count <file|text> |
Count words, lines, characters, sentences, paragraphs, avg word length, and reading time. Works with files or inline text |
tokencount tokens <file> |
Estimate LLM token count using 3 methods (chars÷4, words×1.33, bytes÷3.5), shows cost estimates for GPT-4 class models and context window usage bars |
tokencount freq <file> |
Full word frequency analysis — ranked table with counts, percentages, bar chart, and vocabulary richness score |
tokencount top <file> [n] |
Show top N most common words (default: 20) |
tokencount diff <file1> <file2> |
Compare two files — side-by-side word/line/char/token counts, unique words in each, common vocabulary |
Requirements
- Standard Unix tools:
wc, awk, sort, tr, grep, comm
Examples
# Count everything in a file
tokencount count README.md
# Count inline text
tokencount count "Hello world, this is a test."
# Estimate tokens and costs
tokencount tokens article.txt
# Word frequency analysis
tokencount freq novel.txt
# Top 10 words
tokencount top essay.txt 10
# Compare two drafts
tokencount diff draft-v1.txt draft-v2.txt
1---
2name: tokencount
3description: "Count words, characters, and estimate GPT tokens with readability. Use when tracking length, checking budgets, comparing complexity."
4version: "3.0.0"
5author: "BytesAgain"
6homepage: https://bytesagain.com
7source: https://github.com/bytesagain/ai-skills
8tags: ["token","word","count","text","nlp","ai","gpt"]
9categories: ["Developer Tools", "Utility"]
10metadata:
11 source: https://skillmd.com/skills/bytesagain/tokencount
12---
13
14# TokenCount
15
16A real text and token counter for the terminal. Count words, lines, characters, and sentences. Estimate LLM token usage with cost projections. Analyze word frequency and compare files side by side.
17
18## Commands
19
20| Command | Description |
21|---------|-------------|
22| `tokencount count <file\|text>` | Count words, lines, characters, sentences, paragraphs, avg word length, and reading time. Works with files or inline text |
23| `tokencount tokens <file>` | Estimate LLM token count using 3 methods (chars÷4, words×1.33, bytes÷3.5), shows cost estimates for GPT-4 class models and context window usage bars |
24| `tokencount freq <file>` | Full word frequency analysis — ranked table with counts, percentages, bar chart, and vocabulary richness score |
25| `tokencount top <file> [n]` | Show top N most common words (default: 20) |
26| `tokencount diff <file1> <file2>` | Compare two files — side-by-side word/line/char/token counts, unique words in each, common vocabulary |
27
28## Requirements
29
30- Standard Unix tools: `wc`, `awk`, `sort`, `tr`, `grep`, `comm`
31
32## Examples
33
34```bash
35# Count everything in a file
36tokencount count README.md
37
38# Count inline text
39tokencount count "Hello world, this is a test."
40
41# Estimate tokens and costs
42tokencount tokens article.txt
43
44# Word frequency analysis
45tokencount freq novel.txt
46
47# Top 10 words
48tokencount top essay.txt 10
49
50# Compare two drafts
51tokencount diff draft-v1.txt draft-v2.txt
52```