Björn-Olaf Lange329 downloadsReal-time Claude Code token tracking, plus a rate-limit estimate that gets more precise the more you use it. NextGen sidebar with heatmap and calendar, HTML dashboard. No API key needed.
Token Usage is an Obsidian plugin that tracks Claude Code token consumption from locally stored session files.
Instead of relying on API access or external dashboards, Token Usage reads Claude Code's local JSONL files and displays real-time token statistics directly inside Obsidian — broken down by type, time range, and model.
Full documentation & manual — installation, data sources & transparency, core concepts, settings reference, and an FAQ, all on one searchable page (English, German, French).
For power users: Token Usage tracking is machine-wide by default (see How It Works) — but the Vault / Project Breakdown splits that back down by working directory, so you can see exactly which client, project, or vault consumed how many tokens and when. Export it as a standalone Markdown report to hand to a client as a usage/billing reference.
cleanupPeriodDays directly from Settings, no manual JSON editing~/.claude/projects/), independent of which Obsidian vault is open. Numbers reflect all Claude Code usage on your machine, not just this vault (broken back down per vault/project — see above)As Claude Code usage grows, understanding where tokens actually go becomes important for both cost awareness and workflow optimization.
Most existing solutions require organization-level API access or live in separate dashboards outside your daily workflow.
Claude Code already stores detailed usage information locally in JSONL session files. Those files contain all token data, timestamps, session identifiers, and model information.
Token Usage brings those insights directly into Obsidian, where many users already manage their projects, notes, and knowledge base.
Token Usage scans Claude Code session files stored at ~/.claude/projects/ and extracts token data from every recorded interaction.
Example JSONL entry:
{
"input_tokens": 3,
"cache_creation_input_tokens": 16926,
"cache_read_input_tokens": 0,
"output_tokens": 252
}
The plugin aggregates all four token fields across sessions and time ranges. All calculations run locally on your device.
A live file watcher detects new activity the moment Claude Code writes a response. A configurable fallback polling interval runs in parallel.
This directory is global, not per-vault. ~/.claude/projects/ lives in your user profile, outside any Obsidian vault, and contains one subfolder per working directory Claude Code has ever been run in. Token Usage reads all of them and aggregates the totals. This means:
Because the plugin reads what Claude Code writes to disk, it covers every way you run Claude Code: in a terminal, inside Obsidian, in an editor such as VS Code, and the agent mode built into the Claude desktop app (which runs Claude Code embedded and writes the same session format to its own location — Token Usage reads that too, since v1.8).
It cannot show ordinary chat — the conversations you have in the Claude desktop app or on claude.ai. Those never write token counts to your machine. The only usage signal exposed there is a rounded percentage of your current limit, not the per-request token counts this plugin is built on.
This matters for one number in particular: the rate limit estimates in the dashboard are derived from how many tokens were counted when a limit was actually hit. Chat usage draws on the same plan limit but leaves no local trace, so if you use chat alongside Claude Code, the real limit sits somewhat higher than the estimate shown.
This is the power-user feature: see exactly which vault or client project consumed how many tokens, and when — exportable for billing.
Every JSONL entry Claude Code writes already carries a cwd field — the exact working directory the request ran in. Token Usage uses that to break the machine-wide totals (see above) back down by vault, with no extra setup.
Two levels, shown in different places on purpose:
cwd can drift during the session itself (e.g. a tool call briefly working inside a subfolder) — Token Usage tracks the session's start directory as the stable vault anchor, so that drift never splits one vault's usage into multiple rows or misrepresents how many days you actually worked in it.cwd values seen within a vault. This level is deliberately not shown in the Dashboard (it reflects incidental cwd drift, not real per-topic effort, and gets noisy fast) — it only appears in the Vault_Token_Usage_Projects.md export's "Project Detail" section, for power users who want to dig further (e.g. pull it into Excel).Display name: just the last folder of the path (e.g. Thats_Me), not the full path — kept deliberately simple. If you use more than one Claude Code working directory sharing the same folder name, their usage is combined under that shared name.
Where to see it:
Vault_Token_Usage_Projects.md export — a standalone Markdown report with the same vault-level overview and daily-detail tables, plus an additional "Project Detail" section with the sub-folder breakdown per vault. Written into your vault via the "Create Vault Token Usage Projects report" command (or the path configured in Settings). Handy to hand to a client as a usage/billing reference, separate from your personal Token Usage Report.md.History: the per-vault (and per-project) breakdown is written into the same daily archive files (see Archive below) as a nested byRoot: block in the frontmatter, so it survives beyond your Claude data retention window exactly like the rest of the archive — no separate backfill step needed.

Real-time Claude Code token usage in the Obsidian sidebar.
A rolling window covering the past 5 hours — matching Claude Code's own rate-limit period. Shows Input, Output, C.Write, and C.Read as separate rows. Sub-label: "Rolling window · counts toward rate limit".
Four time-range sections, each showing the same four token rows. A small logarithmic bar next to each value keeps all token types visually readable even when magnitudes differ by orders of magnitude (e.g. Input at a few hundred vs C.Read in the millions).
This Session and Today carry a dynamic sub-label explaining their scope:
These three views — Last 5 Hour Session, This Session, and Today — are independent cuts through the same data. They do not automatically nest inside each other. See the help page for a full explanation.
A stacked percentage bar showing the model distribution across the past 7 days, colored by model family:
| Model | Color |
|---|---|
| Haiku | Cyan |
| Sonnet | Blue |
| Opus | Purple |
| Fable | Amber |
| Other | Gray |
Cache Write (C.Write) and Cache Read (C.Read) are shown as separate rows throughout the sidebar because they have very different cost implications:
The ratio C.Read ÷ C.Write is the Reuse Factor. A high value means the same context is being reused efficiently across many requests.
The dashboard button in the sidebar header generates a self-contained HTML report and opens it in your default browser.
The dashboard includes:
The dashboard uses Chart.js (loaded once from CDN) and works offline after the first load.
The "?" button in the sidebar header toggles between the data view and a built-in glossary. A "← Back" button appears in the header while the glossary is open — click it to return to the data view without hunting for the "?" button again.
The glossary explains:
A link at the bottom of the glossary opens the full documentation page at langeatn.de/media/token-usage/ in your browser — installation, data sources & transparency, core concepts, the archive, the dashboard, every setting, pricing, and an FAQ, all on one searchable page. The page is available in English, German, and French.
The "Create Token Usage report" command (also available via the document icon in the sidebar header) writes a Markdown report file to your vault. The report covers:
The report path is configurable in Settings.
Claude Code deletes its own session files automatically (30 days by default, configurable via cleanupPeriodDays). Once a day's file is gone, no plugin can read it — so Token Usage keeps its own compact, long-term record.
Every day you use Claude Code, the plugin writes one small Markdown file to Token Usage Archive/ in your vault: YAML frontmatter with the day's totals (input, output, cache write, cache read, calls, sessions, model distribution) plus a short human-readable table. It never stores your actual conversations — aggregates only.
On every refresh, the plugin checks all days still available in Claude Code's local files and backfills any day that doesn't have an archive entry yet. This covers a first install (your existing history gets archived immediately) and reopening after Obsidian was closed for a while (any gap gets filled in, as long as Claude Code hasn't already deleted it).
The archive is on by default and can be turned off in Settings, along with the folder path. See Known Behavior for the honest limit on how far back this can reach.
The dashboard and report read the archive back, not just write to it. A "Report period" setting (30 days / 60 days / 6 months / 12 months) controls how far back the daily trend chart, cache-efficiency line, and summary cards go. Anything within your Claude data retention comes from live session files; anything older is filled in from the daily archive automatically — no manual switching between sources. Since a longer period can span vacations, gaps, or quiet weeks, the "Active days" card always shows how many of the selected days actually had usage, and the average-tokens figure is computed per active day, not per calendar day, so a slow month never distorts the number.
main.js, manifest.json, styles.css<vault>/.obsidian/plugins/token-usage/After enabling the plugin:
No additional setup, API keys, or cloud services required.
| Command | Action |
|---|---|
| Open Token Usage | Opens the sidebar panel |
| Create Token Usage report | Writes a Markdown report to your vault |
| Open Token Usage dashboard | Generates and opens the HTML dashboard |
| Create Vault Token Usage Projects report | Writes the per-vault/project breakdown as a separate Markdown file to your vault |
| Setting | Default | Description |
|---|---|---|
| Language | English | Display language for the plugin UI. Switches immediately without restart. Available: English, Deutsch, Français, Italiano. |
| Auto-Refresh (seconds) | 30 | Fallback polling interval in addition to the live file watcher |
| Report path | Token Usage Report.md | Vault-relative path for the generated Markdown report |
| Vault report path | Vault_Token_Usage_Projects.md | Vault-relative path for the per-project/vault usage breakdown, a separate file from the main report |
| Dashboard path | Token Usage Dashboard.html | Vault-relative path for the generated HTML dashboard |
| Report period | 30 days | How far back the dashboard and report look: 30 days, 60 days, 6 months, or 12 months. Beyond your Claude data retention, filled in from the daily archive |
| Enable daily archive | On | Automatically writes a daily Markdown summary to your vault. Turn off if you don't want the plugin creating files |
| Archive folder in vault | Token Usage Archive | Vault-relative folder for the daily archive files |
| Claude data retention (days) | 30 | Reads and writes cleanupPeriodDays directly in Claude Code's own settings.json. A backup (.bak) is created automatically before each change |
Token Usage is built with a local-first philosophy.
Your Claude Code usage data stays on your machine.
Claude Code updates may briefly affect historical data.
Token Usage reads the JSONL files that Claude Code writes locally. When Anthropic ships a Claude Code update that changes how session data is recorded or how internal telemetry is counted, historical values in the 30-day view may temporarily show anomalies.
We review Anthropic's release notes with each Claude Code update and adapt the plugin where needed. Significant compatibility changes are documented in the changelog.
Note for Claude Code v2.1.196 (August 2026): This update fixed a bug where parallel requests were double-counted in telemetry output. Sessions recorded before the fix may show slightly elevated values in the 30-day view. This resolves automatically as those sessions age out of the 30-day window — expected by approximately end of August 2026.
Version number in the sidebar footer shows an outdated version after an update.
This is not a code bug. Obsidian caches the loaded plugin manifest in memory. Toggling the plugin off and on may not fully reinitialize the manifest object. Fix: perform a full Obsidian restart after updating the plugin files. The correct version will display after restart.
The weekly consumption chart uses Claude's billing week boundary.
The dashboard's weekly bar chart aligns to Claude's billing cycle: Sunday 18:00 → Sunday 18:00 Europe/Berlin (= Sunday 16:00 UTC). Weeks where the weekly rate limit was reached are highlighted. Token counts in the rate limits table show the full billing-week total for weekly hits and the 5h window total for session hits — these are the metrics that directly correspond to each limit type.
The 5-hour reset countdown may differ from Claude's own display.
The footer shows "Claude 5h resets in: Xh Ym". The tilde () is intentional — it signals an approximation. Claude Code writes session data to local files after each response completes, not at the moment you send your first message. A long first response (context loading, file reading) can take 10 to 25 minutes before anything is written to the log. The plugin's countdown therefore starts from the first recorded timestamp, which may lag behind the actual session start. For the precise reset time, check the plan usage section in Claude Code or on claude.ai.
The archive backfills, but only what still exists on disk.
Claude Code deletes its own session files automatically — 30 days by default, or whatever you've set for cleanupPeriodDays. The plugin's archive (a small Markdown summary per day, written to a folder in your vault — see Archive below) exists to survive that deletion. Every time the plugin refreshes, it checks all days still available locally and backfills any day that doesn't have an archive file yet — including a first install (it archives your existing history immediately) and reopening after Obsidian was closed for a while.
The limit is physical, not a bug: the archive can only save what's still on disk at the moment it runs. If Obsidian stays closed longer than your retention period, the days in between are deleted by Claude Code before the plugin ever gets a chance to see them, and that gap is unrecoverable. If you use Obsidian less than daily, increase "Claude data retention (days)" in Settings to widen the safety margin.
Contributions, bug reports, feature requests, and suggestions are welcome.
If you encounter a problem or have an idea for improvement, please open an issue in the GitHub repository.
Full documentation, glossary, and manual — installation, data sources & transparency, core concepts, settings reference, FAQ, all searchable on one page: langeatn.de/media/token-usage/
MIT License — see the LICENSE file for details.
Vault_Token_Usage_Projects.md export for billing.au-bar-purple)Built to answer a simple question:
"Where did all my tokens actually go?"