Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>TokenMetreNew to Visual Studio Code? Get it now.
TokenMetre

TokenMetre

vidyudanulaboratories

|
2 installs
| (0) | Free
Token usage, cost estimation, and session analytics for Claude Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

TokenMetre

A VS Code extension that turns raw Claude Code session logs into a rich, interactive token usage dashboard — per question, per model, per hour, per day, and across your entire history.


Why This Exists

Claude Code stores every session as a JSONL file in ~/.claude/projects/. Those files contain precise token counts, model names, and timestamps for every API call — but there's no built-in way to actually read them.

This extension parses those files and gives you:

  • Exactly how many tokens each question cost you
  • Which model answered it and how many times it was called
  • An estimated dollar cost using live Anthropic pricing
  • Aggregates rolled up by hour, day, month, and year across all your projects

Features

Sessions Sidebar

A tree view of every Claude Code session, organised by project.

SESSIONS
├── my-api-service
│   ├── 2026-05-29  e3f1a2b4
│   └── 2026-05-28  9c82d051
└── frontend-app
    └── 2026-05-27  4b71e390

Click any session to open its full token report in a webview panel.


Per-Turn Session Report

Every question you asked in a session gets its own row, showing exactly what it cost.

# Question Calls Input Cache+ Cache~ Output % Eff Cost
1 refactor the auth middleware 8 42.1K 18.3K 120.4K 6.2K 14.2% $0.052
2 add unit tests for the parser 5 38.7K 0 98.1K 4.9K 11.8% $0.038

Each row includes:

  • A progress bar showing that turn's share of total effective input
  • Model chips showing which models answered and how many times (sonnet-4-6 ×8)
  • Timestamp of when you asked the question

Token columns explained:

  • Input — fresh, uncached tokens sent to the model
  • Cache+ — tokens written to the prompt cache (billed at 1.25× input)
  • Cache~ — tokens read from the prompt cache (billed at 0.1× input)
  • Output — tokens generated by the model
  • % Eff — this turn's share of total effective (billable) input

Hourly Breakdown

Within each session report, turns are grouped by the hour they occurred — useful for understanding how your work was spread across a long session.

Hour Turns API Calls Eff. Input Output Cost
2026-05-29 09:00 4 18 280K 32K $0.18
2026-05-29 11:00 7 31 510K 58K $0.34
2026-05-29 14:00 3 12 190K 21K $0.12

Model Breakdown (Per Session)

See which models were used in a session and exactly what each cost you.

Model Calls Input Cache+ Cache~ Output Cost
claude-sonnet-4-6 42 580K 210K 1.4M 98K $3.18
claude-haiku-4-5 8 42K 0 88K 12K $0.09

Token Usage Sidebar — Daily / Monthly / Yearly Aggregates

A second panel aggregates token usage across all sessions, all projects and groups it by time period.

TOKEN USAGE
├── Daily  (31)
│   ├── 2026-05-29   4 sess · 6.2M tok · $18.40   ▶
│   │   ├── sonnet-4-6   ×180 · 5.8M tok · $17.20
│   │   └── haiku-4-5    ×22  · 400K tok  · $1.20
│   ├── 2026-05-28   2 sess · 3.1M tok · $9.20    ▶
│   └── ...
├── Monthly  (3)
│   ├── 2026-05   18 sess · 42M tok · $124.80     ▶
│   └── ...
└── Yearly  (1)
    └── 2026   18 sess · 42M tok · $124.80        ▶

Each period row shows: session count · total tokens · estimated cost.
Expand any period to see the per-model breakdown directly in the tree.


Period Report Webview

Click any date (daily, monthly, or yearly row) to open a dedicated report for that period — a full table of every session that falls within it.

# Date Project / Session Turns Calls Tokens Output Cost
1 2026-05-29 my-api-service · e3f1a2b4 12 48 6.2M 520K $18.40
2 2026-05-29 frontend-app · 4b71e390 5 19 980K 88K $2.90

Includes a model breakdown aggregated across all sessions in the period, and an Export CSV button.


Cost Estimation

All cost figures use Anthropic's published pricing ($/million tokens):

Model family Input Output Cache write Cache read
Opus $15 $75 $18.75 $1.50
Sonnet $3 $15 $3.75 $0.30
Haiku $0.80 $4 $1.00 $0.08

Unrecognised model IDs fall back to family matching (opus / haiku / sonnet default).


CSV Export

Every report — session, period — has an Export CSV button. The exported file includes:

  • Per-turn rows with timestamp, question text, all token columns, and cost
  • An hourly breakdown section (session reports)
  • A model breakdown section with per-model costs

Installation

This extension is not yet published to the VS Code Marketplace. To run it locally:

cd claude-tokens-extension
npm install

Then open the folder in VS Code and press F5 (or run Run Extension from the Run panel). A new Extension Development Host window will open with the extension active.

To compile without launching:

npm run compile

Requirements

  • VS Code 1.85+
  • Claude Code installed and used at least once (so ~/.claude/projects/ exists)
  • Node.js 18+ (for development)

How It Works

Claude Code writes every session event — user messages, assistant responses, tool calls, permission prompts — as a newline-delimited JSON record to ~/.claude/projects/<encoded-path>/<session-id>.jsonl.

Each assistant response record carries a usage object with input_tokens, output_tokens, cache_creation_input_tokens, and cache_read_input_tokens. The extension:

  1. Reads all JSONL files in ~/.claude/projects/
  2. Identifies real human turns (filters out tool-result messages and meta expansions)
  3. Walks each assistant entry's parentUuid chain to find its originating human turn
  4. Deduplicates by message.id so multi-entry streaming responses are counted once
  5. Aggregates token counts and model usage into per-turn buckets
  6. Rolls those buckets up into hourly, daily, monthly, and yearly maps

License

MIT — see LICENSE.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft