Skip to content
Estimates onlyCode Cost Calculator

Prices checked

From a local log

How to Estimate Claude Code Usage

You can price a Claude Code session from the JSONL file already on your machine. The calculator reads it locally. It does not upload the transcript.

1. Find the session file

Claude Code writes one append-only JSONL file per session under ~/.claude/projects/. Each project folder is the working directory with path separators replaced, and each file is a session id. If you set CLAUDE_CONFIG_DIR, start there instead. You only need the file. You do not need an API key.

2. Drop it on the calculator

Open the Claude Code cost calculator, choose “Paste or upload a log”, and drop the file. Parsing uses the File API in the browser. Files over 30MB are refused so a huge transcript does not freeze the tab. Split by session if you hit that cap.

3. Do not double-count streamed rows

One assistant reply is often written as several JSONL lines. They share message.id and requestId, and output_tokens grows until the last line. Summing every line counts the same API call more than once. The parser keeps the line with the largest output count for each message id plus request id. A retry with a new request id stays separate.

Only assistant records carry usage. User messages, attachments, and queue events are ignored. Subagent turns are included, because they are real spend.

4. Keep cache reads and cache writes apart

input_tokens is the uncached tail. cache_read_input_tokens is a cache hit. cache_creation_input_tokens is a cache write. The nested cache_creation object splits writes into ephemeral_5m_input_tokens and ephemeral_1h_input_tokens. A 5-minute write is 1.25× the input rate. A 1-hour write is 2×. The flat total is not added on top of the split.

If the split is missing, the flat write total is priced at the 5-minute rate. Claude Code often uses the 1-hour cache, so that fallback can understate the write. The result says when it made that assumption.

5. Scale a session to a month without faking a giant prompt

“Repeat this workload” multiplies the cost after the long-context check. Twenty Haiku requests of 60,000 tokens stay on the standard Haiku card. One request of 1,200,000 tokens does not. Do not paste a month of tokens into a single row and leave prompt-length pricing on Auto if the model has a threshold.

Codex logs

codex exec --json prints a JSONL stream. A turn.completed line carries usage.input_tokens, cached_input_tokens, and output_tokens. Cached tokens are a subset of input. Session rollouts often live under the Codex home directory, commonly ~/.codex/sessions, and include cumulative token_count events. Bring those files to the Codex cost calculator. The largest cumulative total is used, and per-turn lines in the same file are not added again.

Cursor usage

Cursor does not write the same transcript. Copy token counts from the usage view, or paste a JSON object with input_tokens, output_tokens, and cache_read_tokens. Price Composer and Grok on the Cursor cost calculator. Price Claude models on the home calculator if you want the Claude plan comparison instead.

A labeled paste works too

If you do not have a file, paste lines like these into the log box:

model: claude-sonnet-5-5
input: 85000
output: 220000
cache read: 18000000
1-hour cache writes: 1200000

“input” here means uncached input, matching Claude's input_tokens field.