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.3.tar.gz (24.4 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.3-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6b58cd4e9129e165af1de0d54fb750e88346450937437d20d84cf46190cc54a8
MD5 f7fe2f430818dbe7fad6bd4b8123517b
BLAKE2b-256 0519e0fc35508f1c9308d71b3be99e194c0f9a06c8ba61c7c1f5692d5a94170b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 19ec2b0c812d3331a4d8d2b6e30dabdcf7e42c8ca2d83feceba4a268782fc5a0
MD5 d31a86a2616e39762bd6188c2a592d21
BLAKE2b-256 ee6ed25db04ca7883915447e4cce371366633de744241a7b0bed6878fdd55a45

See more details on using hashes here.

Provenance

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