AI Token Counter
Count exact tokens and estimate costs for OpenAI GPT, Anthropic Claude, and Google Gemini locally in real-time.
Prompt Text
Real-Time Metrics
Cost Estimation (USD)
Price per million tokens: $2.5 (In) / $10 (Out)
About token calculation:
100% exact running offline using OpenAI's official cl100k_base/o200k_base encodings.
Note: Financial estimates are based on current public pricing and assume that the prompt and response do not use context caching or batch discounts.
How to Use the Tool
The AI Token Counter is designed to help developers and prompt engineers optimize their instruction designs, maintain precise control over the context window of popular models, and predict API request budgets.
- Select the Model: Choose the family and specific model in the selection panel below to calibrate the counts and pricing metrics.
- Type or Paste Prompt: The text analysis and token counts are processed locally and deterministically as you type.
- Adjust Response Tokens: Use the estimated response tokens slider to predict the cost of the full roundtrip (input + output).
- Monitor the Context: The progress bar dynamically warns you if your prompt is at risk of exceeding the model's window limit.
Frequently Asked Questions (FAQ)
Why is the number of tokens different from the word count?
Language models process text in chunks called tokens. A token can be an entire word, a part of a word (like a syllable), or even a single character (like punctuation or non-Latin characters). On average, for English, 1 token is about 4 characters or 0.75 words.
Are my prompts sent to any external server?
No. Token counting and cost estimation occur entirely within your own browser. The tokenization logic runs locally via JavaScript (tiktoken) with zero external API calls. Your prompt never leaves your machine.
How does token counting work for Gemini and Claude?
Claude models use a BPE-based tokenizer very similar to the cl100k_base specification of GPT-4, allowing high precision in the browser. For Gemini, the native SentencePiece tokenizer requires large vocabulary files that would degrade page load speed. As an alternative, we provide a robust estimate (4 characters per token) with a transparent warning.
Receive site updates
Subscribe to receive site updates directly to your email
We won't send spam. You can unsubscribe at any time.