Skip to main content

Local web app to explore Claude Code API cost and token usage by day, session, and turn

Project description

Claude Code Cost Explorer

A local Flask web app for exploring Claude Code usage by day, session, and turn. It reads Claude Code JSONL logs from your machine, summarizes token usage, and estimates API cost without sending data anywhere.

No API key is needed. No database is used. No frontend build step is required.

What It Shows

Drill down: Day → Session → Turn

  • 💬 Conversation turns → full messages + collapsible thinking
  • 🛠️ Tool calls → [tool: Bash], [3 tools: Read, Write, Glob] → inputs + raw output

At each level it shows cost and token summaries. Turn detail pages can show the full user message, assistant content blocks, collapsible thinking blocks when present in the source log, and tool call inputs/results.

Home Sessions Detail
Home Sessions Detail

Install

pip install claude-code-cost-explorer

Run

ccx

Then open:

http://localhost:5050

You can also choose a port:

ccx --port 5051

To point at a custom projects directory instead of ~/.claude/projects/:

CLAUDE_PROJECTS_DIR=/path/to/projects ccx

Requirements

  • Python 3.10 or newer
  • Claude Code installed and used at least once
  • A local ~/.claude/projects/ directory containing Claude Code session JSONL files

How It Works

Claude Code Cost Explorer scans:

~/.claude/projects/*/*.jsonl

For each valid session file, it parses assistant records with token usage, associates them with the preceding user prompt or tool result, estimates cost from the model pricing table, and renders the result through local Flask/Jinja pages.

Session Naming Tips

Session titles come from Claude Code session metadata. Deliberate names make the session list much easier to scan when comparing costs across similar work.

How When
claude -n "my-feature" At startup
/rename my-feature During a conversation
Press R in the /resume picker After the fact

If you do not name a session, Claude assigns a random slug.

Development

uv run pytest -q
uv run ruff check .
uv run ruff format .

The project intentionally stays small: Flask, standard Python modules, Jinja templates, and tests.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claude_code_cost_explorer-0.1.6.tar.gz (514.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claude_code_cost_explorer-0.1.6-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file claude_code_cost_explorer-0.1.6.tar.gz.

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.6.tar.gz
Algorithm Hash digest
SHA256 d916cdf42d355e17f4d4d418daca71ef6f256b6fc72d54bf421c44581f2d335d
MD5 94b0d0c91921382f963f74d172279d04
BLAKE2b-256 948c5a3999344c824cbf87837086be336723f304049e02b75495ac6e7146a0c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_cost_explorer-0.1.6.tar.gz:

Publisher: publish.yml on ranajoy-dutta/claude-code-cost-explorer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file claude_code_cost_explorer-0.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 895d123fab46311d31080774ba37aedc7600eba07524b5633ec80e58818b69c8
MD5 5878722ba7b5b324acb835e0c7cddfc8
BLAKE2b-256 381329ce045db5db02498db8ea0b18e897fd62656d5dcc5a497d5bf57ea4d100

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_cost_explorer-0.1.6-py3-none-any.whl:

Publisher: publish.yml on ranajoy-dutta/claude-code-cost-explorer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page