Claude Token Counter

Count tokens for Anthropic's Claude models (Opus 5.5, Sonnet 5.5, Opus 4.7, Sonnet 4.6, Haiku 4.5) with cost estimates against Anthropic's list prices. Anthropic doesn't ship a JavaScript tokenizer, so this is a heuristic estimate, not an exact count: use the official /v1/messages/count_tokens endpoint when you need billing-grade numbers. Note that models from Claude Opus 4.7 on use a newer tokenizer that fits about 555k words in 1M tokens, versus about 750k words on earlier models (Anthropic models overview). Runs in your browser; text never leaves the page.

Advanced options

Paste text and click Count tokens.

How to use the Claude Token Counter

Paste any text, pick the Claude variant you'll be calling, and press Count tokens. The tool returns the token count, character count, and (with cost enabled) per-call, monthly, and annual cost projections based on Anthropic's current API list pricing.

For production workloads where exact billing matters, hit Anthropic's /v1/messages/count_tokens endpoint instead — same request shape as /messages, just returns the token count without running the model. That endpoint is free. For pre-flight sizing where you haven't built the API client yet (or you don't want to paste production data through an API call), this tool is the faster path.

What is Claude's tokenizer

Claude uses a SentencePiece-style Byte Pair Encoding tokenizer with a vocabulary in the range of ~150K tokens. Anthropic hasn't published the exact vocabulary or made it available as a public library (unlike OpenAI's tiktoken), so direct in-browser tokenization isn't possible without an API call.

Empirically, Claude's tokenizer behaves similarly to GPT-3.5's cl100k_base for English text — about 4 characters per token on average. It's slightly looser (more tokens) than o200k_base used by GPT-4o and GPT-5. For code, especially with single-character identifiers and dense punctuation, Claude is in the same ballpark as cl100k_base. For non-Latin scripts (Mandarin, Hindi, Arabic), Claude's tokenizer can produce 1.5-2x more tokens than o200k_base, which matters for multilingual cost analysis.

Pricing comparison across the Claude line

For 1,000 tokens of input + 1,000 tokens of output, the per-call cost works out to:

ModelInput ($/M)Output ($/M)Cached ($/M)Per-call (1K + 1K)
Claude Opus 5.5$4.00$20.00$0.20$0.024
Claude Sonnet 5.5$2.00$10.00$0.10$0.012
Claude Opus 4.7$5.00$25.00$0.50$0.030
Claude Sonnet 4.6$3.00$15.00$0.30$0.018
Claude Haiku 4.5$1.00$5.00$0.10$0.006

Prices are Anthropic's list prices per million tokens (checked 2026-11-12 on platform.claude.com). Opus 5.5 costs twice Sonnet 5.5 per token; Haiku 4.5 is the cheapest of these and the fastest. Cache hits cost 10% on Opus 4.7, Sonnet 4.6 and Haiku 4.5 and 5% on Opus 5.5 and Sonnet 5.5 of the base input price. Cached pricing applies only to input tokens that match a previously-cached prefix; it does not discount output.

Common use cases

  • System prompt sizing. Pasting a Sonnet system prompt to see whether it fits in the cacheable prefix (the minimum cacheable prompt is 1,024 tokens for Sonnet 4.6 and 512 for Sonnet 5.5, so shorter prompts don't benefit from prompt caching at all).
  • RAG chunk planning. Counting your average retrieved chunk to size a top-k retrieval that fits the model's context without wasting it.
  • Comparing Claude to GPT. Same text into both this tool and the OpenAI Token Counter to see where the per-token-cost difference goes once tokenization is accounted for.
  • Pre-flight budget for a migration. If you're moving a workload from GPT-4o to Claude Sonnet, the token-count delta plus the per-token price delta gives you the real monthly cost change.
  • Long-context cost estimation. Claude 4.6 and later models include the full 1M-token context at standard pricing, so per-call cost scales linearly. A 150K-token input on Sonnet 4.6 costs $0.45 per call before output. Knowing the count up front avoids surprises.

Frequently asked questions

Why is this an estimate and not the exact Anthropic count?

Anthropic does not ship an official JavaScript tokenizer. The exact count is only available via the /v1/messages/count_tokens endpoint, which requires an API call. This tool uses a calibrated heuristic that matches Anthropic's API count within about 5% for English text and within 10% for code. For exact production billing, use the API endpoint.

How do Claude tokens differ from OpenAI tokens for the same text?

Claude's tokenizer (a SentencePiece-style BPE) typically produces 5-15% more tokens than GPT-4o (o200k_base) for the same English text, and roughly the same as GPT-3.5's cl100k_base. For code and non-English text the difference is larger. Use the Multi-Model Token Comparison tool to see the side-by-side.

Does Claude charge for system prompts and tool definitions the same way?

Yes — every input token is billed at the same rate per model, whether it's in a system prompt, user message, tool definition, or assistant prefix. The big exception is prompt caching: cache hits cost 10% on Opus 4.7, Sonnet 4.6 and Haiku 4.5 and 5% on Opus 5.5 and Sonnet 5.5 of the base input price. Prompts below the model's minimum cacheable length are not cached (512 tokens on Opus 5.5 and Sonnet 5.5, 1,024 tokens on Sonnet 4.6, 2,048 tokens on Opus 4.7, 4,096 tokens on Haiku 4.5), and the default cache lifetime is 5 minutes.

What's the cheapest Claude option?

Of the models in this tool, Claude Haiku 4.5 is cheapest at $1.00/M input and $5.00/M output, with cache hits at $0.10/M. Anthropic also lists Claude Haiku 5.5 from $0.10/M input and $0.50/M output, priced by prompt length (higher above 100,000 prompt tokens). In the Sonnet line, Sonnet 5.5 at $2.00/$10.00 is cheaper than Sonnet 4.6 at $3.00/$15.00. Prices: Anthropic pricing page, checked 2026-11-12.

How big is the Claude context window?

Opus 5.5, Sonnet 5.5, Opus 4.7 and Sonnet 4.6 have a 1M-token context window with up to 128K output tokens; Haiku 4.5 has 200K context and 64K output (Anthropic models overview). On Claude 4.6 and later models the full 1M window is billed at standard per-token prices.

Can I use this for cost estimation?

Yes. Enable "Show cost" in the options, enter monthly call volume, and the tool multiplies tokens by Anthropic's current per-million-token pricing. The cached-input cost mode applies the model's cache-hit price (10% on Opus 4.7, Sonnet 4.6 and Haiku 4.5 and 5% on Opus 5.5 and Sonnet 5.5 of base input); use it when most of your input is a stable system prompt that gets cache hits.