Claude Code Token Calculator
Paste a Claude Code session, a file, or raw tool output below. We'll estimate the token count, how much of it is compressible, and roughly what it costs — plus what TokenPincherwould save you on it.
These are estimates, not exact counts. Token count uses a ~4 characters-per-token heuristic (formula: characters ÷ 4) — the real Claude tokenizer will differ, sometimes significantly, depending on content. Compressibility is estimated from duplicate lines, long whitespace runs, and JSON/log-like structure in your input — repetitive tool output and logs score higher, prose scores lower. The savings projection below scales with that same estimate rather than a flat rate, so it will vary paste to paste. Cost assumes $3 per 1M input tokens (Claude Sonnet-class input pricing); your actual model and pricing may differ.
How token counting works
Claude doesn't read text character by character or word by word — it breaks text into tokens, which are roughly chunks of 3-4 characters for English text (shorter for common words, longer for rare ones, and different again for code or non-English text). The real tokenizer uses a learned vocabulary, so any character-based formula is only an approximation. This calculator uses a simple ~4 characters-per-token estimate because it's transparent and good enough to get a ballpark — but if you need an exact count, use Anthropic's own tokenizer.
Why your Claude Code sessions burn tokens
Claude Code is agentic: it reads files, runs commands, greps across your codebase, and feeds all of that output back into the model as context. Because the API is stateless, every turn resends the entireconversation so far — every message, every file read, every command's output. On a long session, tool output usually dwarfs anything you actually typed, which is why usage limits tend to hit hardest on your most productive sessions.
For the full breakdown — where the tokens actually go, and every tactic for cutting them down — read the complete guide to reducing Claude Code token usage.
FAQ
- How accurate is this token calculator?
- It's an estimate, not the real Claude tokenizer. We use a ~4 characters-per-token heuristic, which is a reasonable approximation but can be off by 20% or more depending on the content — code, JSON, and non-English text all tokenize differently than plain English prose.
- Why does Claude Code burn through tokens so fast?
- Claude Code resends your entire conversation history on every turn, including every file it read, every command it ran, and every line of tool output. Large tool outputs — grep results, test logs, file dumps — usually make up the majority of a session's token spend, not your actual prompts.
- What counts as "compressible" in the estimate above?
- The compressibility estimate looks at signals in your pasted text: repeated lines (common in logs and repeated stack frames), long whitespace runs (aligned columns, indentation-heavy output), and JSON/log-like structure. Repetitive tool output scores higher; prose scores lower. It's a proxy, not a measurement of what any specific compressor would achieve.
- Does this calculator send my pasted text anywhere?
- No. The estimate runs entirely in your browser — nothing you paste is sent to a server.
Stop estimating — actually cut your token usage
TokenPincher compresses Claude Code tool output and logs, lossless by default, before they hit the model — no desktop app, no workflow change. See how it works with Claude Code.
npx tokenpincher init