GUIDE

How to Track Your Claude Code and Codex Token Usage

A step-by-step guide to finding where Claude Code and OpenAI Codex quietly log every token you spend, reading those logs, and turning them into a clear picture of your usage and cost — all on your own machine, fully offline.

Last updated 11 July 2026

Short version: both Claude Code and Codex keep a local log of every session. Claude Code stores them at ~/.claude/projects/**/*.jsonl; Codex at ~/.codex/sessions/**/rollout-*.jsonl. Those files hold token counts, model names, and timestamps — never your source code. You can read them by hand, with a CLI, or with a visual dashboard.

Where Claude Code and Codex store your usage logs

Both tools write a local log file for every session, with no setup on your part. Here is where to look:

ToolmacOS / LinuxWindows
Claude Code~/.claude/projects/**/*.jsonl%USERPROFILE%\.claude\projects\
OpenAI Codex~/.codex/sessions/**/rollout-*.jsonl%USERPROFILE%\.codex\sessions\

Claude Code writes one JSONL file per session, grouped into a subfolder per project (its name is derived from that project's path). Codex writes one rollout-*.jsonl per session inside dated subfolders.

What's inside the logs — and what isn't

Each line is one event. Every assistant reply carries a usage block recording the tokens that round-trip spent. You can read:

  • Token counts for four classes: input, output, cache-read, and cache-write
  • The model that answered (for example, a Claude or GPT model identifier)
  • Timestamps, a session id, the project folder name, and usually the git branch
  • An AI-generated session title and the message-type structure (used to tell real user turns from tool results)
  • But not your source-code files

The raw files are verbose — they also carry system prompts and message text. But to total your usage you only need the token and model fields, and a good tool touches only those. Token Forest, for instance, reads only the counts and metadata; it never copies your prompts, replies, or source code into its own data, and never uploads anything.

The four token classes, and why raw counts look huge

Cache-read tokens usually dominate the raw counts, yet they are the cheapest class per token. So looking at a raw token total alone, it's easy to be alarmed by an enormous number.

In Token Forest's own six-week sample, cache reads were about 57% of real cost while input and output together were only about 24%. In other words, a huge raw-token number doesn't mean a huge bill. Judge spend by estimated cost, not by raw token totals.

Method 1: read the logs by hand

  1. Open Claude Code's log folder at ~/.claude/projects/. You'll see one subfolder per project; inside are the .jsonl session files.
  2. Open Codex's folder at ~/.codex/sessions/. Sessions are saved as rollout-*.jsonl inside dated subfolders.
  3. Open any file in a text editor. Every line is one JSON event; assistant replies include a usage object with the four token counts.
  4. To total them without reading every line, pipe a file through a tool like jq. Handy for a spot check — but tedious across hundreds of sessions.
# Show the token usage from one Claude Code session
jq 'select(.message.usage) | .message.usage' \
  ~/.claude/projects/<project>/<session>.jsonl

Method 2: use a command-line tool

If you'd rather not parse JSON yourself, a CLI can total it up. ccusage (open-source, by ryoppippi, on npm) reads the same ~/.claude logs — and now Codex logs too — and prints daily, monthly, and per-session cost tables in your terminal. Run it with npx ccusage. It's a well-loved, independent tool and a great fit if you live in the terminal.

Method 3 (the easy way): Token Forest's offline dashboard

If you want that same data as charts you can read at a glance — without touching the command line — install Token Forest. It reads the very same local logs, computes everything on your device, and shows three reconciling views. Nothing is uploaded; it works with the network fully switched off.

  1. Download and install Token Forest (Windows 10/11 or macOS). It's a free public beta.
  2. On first launch it scans your local Claude Code and Codex logs — no account, no API key.
  3. Open the dashboard and read three views (below).
  • Growth — your usage drawn as a pixel tree that grows through stages, with days planted and 'this tree ≈ $X'.
  • Usage — daily / weekly / monthly charts, a per-model breakdown for both Claude Code and Codex, a 26-week heatmap, burn rate, and a per-project breakdown.
  • Chats — one line per conversation: title, project, prompt count, all four token classes, and an estimated cost.

The cost figures here are an offline estimate from a bundled price table, so they may differ from your actual Anthropic or OpenAI bill — but they're computed the same way every time, which makes them ideal for spotting trends.

Which method should you use?

ApproachBest forEffortCost view
By hand (jq)one-off spot checkshighyou compute it
CLI (e.g. ccusage)terminal fans, quick totalslowtables in the terminal
Token Foresta visual, ongoing picturelowestcharts + offline estimate

Key takeaway: the logs are already on your machine — you need no API key and no internet connection to see your Claude Code and Codex usage. Read them by hand for a spot check, with a CLI like ccusage for quick totals, or with Token Forest for an at-a-glance dashboard. Whichever you pick, judge spend by estimated cost, not raw token counts.

Read more

Where does Claude Code store its usage logs?

Under ~/.claude/projects/ (on Windows, %USERPROFILE%\.claude\projects\), as one JSONL file per session, grouped into a folder per project. Codex uses ~/.codex/sessions/ with files named rollout-*.jsonl.

How can I see my Claude Code costs?

The logs record token counts, not dollars. To get a cost figure you multiply those counts by model prices. A CLI like ccusage or Token Forest's dashboard does this for you — but note that any offline number is an estimate and may differ from your real bill.

Do these tools read my code or my prompts?

The log files themselves contain message text, but usage tracking only needs the token and model fields. Token Forest reads only counts and metadata; it never copies your prompts or source code into its data, and never uploads anything.

How do I monitor Codex usage the same way?

Codex writes rollout-*.jsonl files under ~/.codex/sessions/. Read them by hand, or use a tool that supports both — ccusage and Token Forest each read Claude Code and Codex logs together.

Is Token Forest just a front-end for ccusage?

No. Token Forest is an independent app that reads the same local logs; it shares no code with ccusage. ccusage is a great terminal CLI; Token Forest is a visual, offline dashboard (and a pixel-tree desktop pet). Pick whichever fits how you work.

See your usage as a living tree

Install the free public beta and let Token Forest turn your local Claude Code and Codex logs into a dashboard — and a pixel tree — entirely on your machine.