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.5.tar.gz (503.6 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.5-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ba0edd385f8012adca250b1af2229a1c4435b4fb3721b595b6d495b2c1d5ac19
MD5 da9fd102294e43b30ce5bf38ef2b92b5
BLAKE2b-256 e3e97c2bbc88e88c404de0d390a6d89d0a63033859ef2c0d9a28855992379f80

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for claude_code_cost_explorer-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8613f1bba7a074185fca9bb2075441cce9bd6e0a60adb8222906842555d16c2f
MD5 97a14202544dce41b41726bee8c8b646
BLAKE2b-256 24841d1e515fa6ed7cbe4016ae45eec2be9617b77e7f53dd08fbcd68461f553f

See more details on using hashes here.

Provenance

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