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

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.4.tar.gz (489.5 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.4-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 4f8c5e94e0320e5a1a0a12b4b47cf064702dd7ea13efc45cc80572f3d0faf9b3
MD5 333b7c521d1587435a0363575b7e7d51
BLAKE2b-256 8774b6aff03c10c13fff1f34dd8693cf630e45834a308fb07764854e5c35c698

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_cost_explorer-0.1.4.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.4-py3-none-any.whl.

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3770641856cd4daba25b13e32378b892b9ce8798be8407f63225f3eb448d724a
MD5 347126e7ccabf411691307f82a9696f1
BLAKE2b-256 6412e960798e1fda6b3c4980484b289d7506d75a0d8db1ae149105891356aa5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for claude_code_cost_explorer-0.1.4-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