tokcount › claude

Claude token counter.

Count tokens for Claude Opus 4.7, Claude Sonnet 4.6, and Claude Haiku 4.5. Free, browser-only. No API key. No signup. Instant cost estimate at current Anthropic rates.

open tokcount → browser extension →
$ npm i -g @v0idd0/tokcount # one-time install — runs everywhere afterwards $ tokcount prompt.md --model claude model: claude-sonnet-4-6 · tokens: 4,218 · cost: $0.0127 in + $0.0634 out $ tokcount context/ --model claude-opus-4-7 --all model: claude-opus-4-7 · tokens: 28,504 · cost: $0.4276 in + $2.1378 out $ cat system.md user.md | tokcount --model claude-haiku-4-5 model: claude-haiku-4-5 · tokens: 1,093 · cost: $0.0009 in + $0.0044 out well within 200K context window (0.5% used)

Claude API pricing — 2026.

tokcount calculates these costs automatically when you run a count command.

Opus 4.7

claude-opus-4-7
context window: 200K tokens
input$15 / 1M
output$75 / 1M
best forcomplex reasoning

Haiku 4.5

claude-haiku-4-5
context window: 200K tokens
input$0.80 / 1M
output$4 / 1M
best forhigh-volume tasks

Pricing from Anthropic's public API docs. Context input caching available at discounted rates on all models — tokcount supports --cache flag for cached-cost estimation.

Count Claude tokens in the browser.

The tokcount browser extension shows live token counts as you type inside the Claude.ai chat interface — including system prompt tokens, conversation history, and remaining context budget.

CLI — tokcount
  • count files, directories, stdin
  • multi-model cost comparison with --all
  • tag-based model groups (--tag cheap)
  • pipe into shell scripts
Extension — live in Claude.ai
  • inline token count as you type
  • context window % used
  • cost estimate per message
  • Chrome + Firefox + Edge
install tokcount extension →

Claude tokenization — FAQ.

How do I count tokens for a Claude prompt?
Install tokcount with npm i -g @v0idd0/tokcount, then run tokcount yourfile.md --model claude. This uses claude-sonnet-4-6 as the default model alias. You can also specify exact model IDs: --model claude-opus-4-7 or --model claude-haiku-4-5. For stdin input: echo "your prompt" | tokcount --model claude.
Is Claude's tokenizer the same as GPT-4?
No. Claude uses Anthropic's own BPE-based tokenizer, which is similar in structure to GPT-4's cl100k_base but not identical. English text typically tokenizes at a similar rate (roughly 1 token per 0.75 words or 4 characters), but the exact boundaries differ. For non-English text, code, and special characters, Claude and GPT-4 can diverge by 5–15% on the same input. tokcount uses model-specific approximations accurate to within 1–2% for typical English text.
What is the maximum context window for Claude?
All current Claude models (Opus 4.7, Sonnet 4.6, Haiku 4.5) support a 200,000-token context window — approximately 150,000 English words, or a full-length novel. Extended thinking mode (Sonnet 4.6+) supports up to 64,000 output tokens. tokcount warns you when your input approaches the context limit.
Can I count Claude tokens without an API key?
Yes. tokcount counts tokens entirely offline, with no connection to Anthropic's servers. The token count is an estimate using a local BPE implementation — close enough for cost planning and context-window checks, without needing an API key.
How do I compare Claude costs across models?
Run tokcount prompt.md --model claude --all to see a cost breakdown across all Claude models at once. You can also tag-filter: tokcount prompt.md --tag anthropic shows only Anthropic models, while tokcount prompt.md --tag cheap shows budget models across all providers for comparison.
other model counters
GPT-4o token counter → Gemini token counter → all 60+ models →

power user?

use tokcount daily? tools.voiddo Pro · $9 one-time

supports 67 free tools · Pro license via Paddle · one flat price, no subscription