Quick answer
Read each JSONL log under `~/.claude/projects`, keep the timestamp, session ID, model, and token fields, and drop message content. Write one row per assistant message to CSV. Cost is computed from tokens and current rates, not copied from the log.
Columns to keep
| Column | Use | Sensitive |
|---|---|---|
| timestamp | Trend | No |
| session_id | Grouping | No |
| project | Attribution | Mildly |
| model | Efficiency | No |
| input_tokens | Volume | No |
| cache_read | Discount | No |
| cache_write | First-turn cost | No |
| output_tokens | Generation | No |
Prompts and file contents are sensitive and unnecessary for a usage report.
Shape the export
for f in ~/.claude/projects/*/*.jsonl; do
jq -c 'select(.type=="assistant") | {ts:.timestamp, session:.sessionId, model:.message.model, usage:.message.usage}' "$f"
done > claude-usage.ndjsonField names vary by version. Inspect one line before assuming the paths.
Export without exporting prompts
The session files contain full conversations. Any export for reporting should reduce them to tokens, model, timestamp, and project before it leaves your machine.
- Parse the JSONL files for the period.
- Keep the usage fields and drop message content.
- Write one row per assistant turn or per session.
- Record the source path and the export date.
- Store the export somewhere with the same access rules as the logs.
UsageAtlas shows the aggregates without a script, and the token report guide covers the field list.
Questions, answered
Does Claude Code have a CSV export?
Not a general one. The logs are JSONL, so export means parsing them or using a tracker.
Can I export chat usage?
Chat usage is not stored in the same local logs. Use the account usage view or billing export.
Is the export safe to share?
Only if it excludes prompts, file paths, and content. Token and cost fields alone are safe.