Track Claude API token usage and costs from local JSONL session files.
This tool scans local Claude JSONL session files (~/.claude/projects/**/*.jsonl) and displays token usage and costs for:
- Today
- This Week
- This Month
Inspired by CodexBar π Shoutout to Peter Steinberger for creating CodexBar, the awesome macOS menu bar app that tracks Claude Code and OpenAI Codex usage. This CLI tool brings similar functionality to the command line for detailed token analysis!
# Clone the repository
git clone https://github.com/jwmoss/claude-usage.git
cd claude-usage
# Install with uv
uv sync
# Or install as a tool
uvx install .# Default: Show daily breakdown for last 7 days
uv run claude-usage
# Show more days (daily view)
uv run claude-usage --days 14
# Show summary view (Today/Week/Month + model breakdown)
uv run claude-usage --summary
# Output as JSON
uv run claude-usage --json
# Show help
uv run claude-usage --help Claude Token Usage - Last 7 Days
βββββββββββββββ³ββββββββ³βββββββββ³βββββββββ³βββββββββββββββ³ββββββββββ
β Date β Input β Output β Cache β Total Tokens β Cost β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Mon, Jan 20 β 1.2K β 345 β 5.1K β 6.6K β $0.12 β
β Tue, Jan 21 β 2.3K β 567 β 8.2K β 11.1K β $0.23 β
β Wed, Jan 22 β 1.8K β 234 β 3.4K β 5.4K β $0.09 β
β Thu, Jan 23 β 3.1K β 678 β 12.5K β 16.3K β $0.31 β
β Fri, Jan 24 β 2.7K β 456 β 9.8K β 13.0K β $0.25 β
β Sat, Jan 25 β 0 β 0 β 0 β 0 β $0.00 β
β Sun, Jan 26 β 0 β 0 β 0 β 0 β $0.00 β
βββββββββββββββΌββββββββΌβββββββββΌβββββββββΌβββββββββββββββΌββββββββββ€
β Total β 11.1K β 2.3K β 39.0K β 52.4K β $1.00 β
βββββββββββββββ΄ββββββββ΄βββββββββ΄βββββββββ΄βββββββββββββββ΄ββββββββββ
The summary view shows two tables:
1. Time Period Summary:
Claude Token Usage - Summary
βββββββββββββββββββ³βββββββββ³βββββββββ³βββββββββ³βββββββββββββββ³βββββββββββ
β Period β Input β Output β Cache β Total Tokens β Cost β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Today β 3.1K β 678 β 12.5K β 16.3K β $0.31 β
β Jan 26, 2026 β β β β β β
β This Week β 11.1K β 2.3K β 39.0K β 52.4K β $1.00 β
β Jan 20 - Jan 26 β β β β β β
β This Month β 23.5K β 5.7K β 89.2K β 118.4K β $2.15 β
β January 2026 β β β β β β
βββββββββββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββββββββ΄βββββββββββ
2. Model Breakdown:
Claude Token Usage - By Model
ββββββββββββββββ³βββββββββββ³βββββββββ³βββββββββ³βββββββββ³βββββββββββββββ³βββββββββββ
β Model β Messages β Input β Output β Cache β Total Tokens β Cost β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β claude-opusβ¦ β 12 β 8.2K β 2.1K β 34.5K β 44.8K β $1.15 β
β claude-sonnβ¦ β 38 β 15.3K β 3.6K β 54.7K β 73.6K β $1.00 β
β claude-haikβ¦ β 5 β 0 β 0 β 0 β 0 β $0.00 β
ββββββββββββββββΌβββββββββββΌβββββββββΌβββββββββΌβββββββββΌβββββββββββββββΌβββββββββββ€
β Total β 55 β 23.5K β 5.7K β 89.2K β 118.4K β $2.15 β
ββββββββββββββββ΄βββββββββββ΄βββββββββ΄βββββββββ΄βββββββββ΄βββββββββββββββ΄βββββββββββ
The model breakdown shows:
- Which Claude models you're using (Opus 4, Sonnet 4, Haiku 3.5, etc.)
- How many messages each model handled
- Token usage breakdown per model
- Cost per model
Perfect for: High-level overview of your usage patterns and costs across different time periods and models.
{
"today": {
"date": "2026-01-26",
"tokens": {
"input": 3100,
"output": 678,
"cache": 12500,
"total": 16278
},
"costs": {
"input": 0.09,
"output": 0.10,
"cache": 0.12,
"total": 0.31
}
},
"week": {
"date_range": "2026-01-20 to 2026-01-26",
"tokens": {
"input": 11100,
"output": 2300,
"cache": 39000,
"total": 52400
},
"costs": {
"input": 0.33,
"output": 0.35,
"cache": 0.32,
"total": 1.00
}
}
}- Daily breakdown - See usage for each of the last 7 days (default) with totals
- Summary view - Today/Week/Month summary + model breakdown with
--summary - Customizable range - Show any number of days with
--days N(works with daily view) - Rich table output - Clean, professional tables using the Rich library (like optionctl)
- JSON export - Machine-readable output for scripting and automation
- Smart number formatting - Displays large numbers as 52.1M instead of 52,104,345
- Automatic deduplication - Handles streaming responses correctly
- Model-aware pricing - Accurately calculates costs based on model type (see Pricing section below)
- Timezone aware - Properly handles local vs UTC timestamps
The tool calculates costs using official Claude API pricing (per million tokens):
| Model | Input | Output | Cache Write | Cache Read |
|---|---|---|---|---|
| Claude Opus 4 | $15.00 | $75.00 | $18.75 | $1.50 |
| Claude Sonnet 4 | $3.00 | $15.00 | $3.75 | $0.30 |
| Claude 3.5 Sonnet | $3.00 | $15.00 | $3.75 | $0.30 |
| Claude 3.5 Haiku | $0.80 | $4.00 | $1.00 | $0.08 |
Costs are calculated by:
- Reading token usage from JSONL session files
- Identifying the model used for each message
- Applying model-specific pricing to input, output, cache write, and cache read tokens
Want to see usage by model? Use claude-usage --summary to see both time-based summary and model breakdown.
# Install dev dependencies
uv sync --all-groups
# Run linter
uv run ruff check .
# Format code
uv run ruff format .
# Run type checker
uv run ty check src/
# Run tests
uv run pytestMIT