Token Calculator for LLMs
Free AI Token Counter & API Cost Calculator for GPT-5.4, Claude Opus 4.6, Gemini 3 Pro and other LLMs
Token Calculator(Loading tokenizer...)
How to Use the AI Token Calculator
Paste Your Text
Enter or paste the text you want to analyze into the text area above.
View Token Count
See the instant token count using OpenAI's official tiktoken BPE tokenizer algorithm.
Compare API Costs
Review the pricing table to compare costs across GPT-5.3, Claude Opus 4.6, Gemini 3 Pro, and other models.
Optimize Your Prompts
Use the token visualization to identify opportunities to reduce token usage and API costs.
Understanding Tokenization
This tool functions as a universal tokenizer for OpenAI, Anthropic, and Google models. We use official Tiktoken libraries and model-specific tokenizers for 99% accuracy in token counting.
What is BPE (Byte-Pair Encoding)?
BPE is the tokenization algorithm used by GPT models. It breaks text into subword units by iteratively merging the most frequent character pairs. For example, "tokenization" might become ["token", "ization"]. This allows models to handle rare words efficiently while keeping vocabulary size manageable.
What is a Context Window?
The context window is the maximum number of tokens an LLM can process in a single request (input + output combined). GPT-5.3 offers 256K tokens, Claude Opus 4.6 provides 1M tokens, and Gemini 3 Pro supports up to 2M tokens. Exceeding this limit will cause truncation or errors.
What is Cached Input Pricing?
Cached input pricing offers significant discounts (up to 90% off) when you reuse the same prompt prefix across multiple API calls. This is ideal for system prompts, few-shot examples, or document analysis where the context remains constant while only the query changes.
Input vs Output Token Costs
Output tokens are typically 2-4x more expensive than input tokens because they require the model to perform sequential generation. To optimize costs, design prompts that get concise responses, use output length limits, and choose the right model for each task.
Word-to-Token Conversion Guide
Token counts vary significantly based on content type and language. Use this reference to estimate token usage before running your text through the calculator.
| Content Type | Example | Ratio | 1000 Words ≈ | Notes |
|---|---|---|---|---|
| English Text | Hello world | ~1.3 tokens/word | ~1,300-1,500 | Standard prose averages 1.3 tokens per word |
| Code (Python/JS) | def func(): | ~2-3 tokens/word | ~2,000-3,000 | Symbols, operators, and syntax increase token count |
| Chinese/Japanese | 你好世界 | ~2+ tokens/char | ~2,000+ | CJK characters often split into multiple tokens |
| Technical Writing | API endpoint | ~1.5 tokens/word | ~1,500-1,800 | Technical terms and abbreviations vary |
| JSON/XML Data | {"key":"value"} | ~3-4 tokens/word | ~3,000-4,000 | Structural characters add significant overhead |
English Text
Standard prose averages 1.3 tokens per word
Code (Python/JS)
Symbols, operators, and syntax increase token count
Chinese/Japanese
CJK characters often split into multiple tokens
Technical Writing
Technical terms and abbreviations vary
JSON/XML Data
Structural characters add significant overhead
Compare Token Costs
Compare API pricing across all major LLM providers. Prices shown are per 1 million tokens. The calculated prices below reflect the cost for your current input text.
| Model | Provider | Context | Input/1M Tokens | Input(cached)/1M Tokens | Output/1M Tokens | Input Price | Input(cached) Price | Output Price |
|---|---|---|---|---|---|---|---|---|
| GPT-5.4 | OpenAI | 1M | $2.5 | $0.25 | $15 | $0.0000 | $0.0000 | $0.0000 |
| GPT-5 mini | OpenAI | 400K | $0.25 | $0.025 | $2 | $0.0000 | $0.0000 | $0.0000 |
| Claude Opus 4.6 | Anthropic | 200K | $5 | $0.5 | $25 | $0.0000 | $0.0000 | $0.0000 |
| Claude Opus 4.5 | Anthropic | 200K | $5 | $0.5 | $25 | $0.0000 | $0.0000 | $0.0000 |
| Claude Sonnet 4.6 | Anthropic | 200K | $3 | $0.3 | $15 | $0.0000 | $0.0000 | $0.0000 |
| Claude Sonnet 4.5 | Anthropic | 200K | $3 | $0.3 | $15 | $0.0000 | $0.0000 | $0.0000 |
| Claude Sonnet 4 | Anthropic | 200K | $3 | $0.3 | $15 | $0.0000 | $0.0000 | $0.0000 |
| Claude Haiku 4.5 | Anthropic | 200K | $1 | $0.1 | $5 | $0.0000 | $0.0000 | $0.0000 |
| Claude Haiku 3.5 | Anthropic | 200K | $0.8 | $0.08 | $4 | $0.0000 | $0.0000 | $0.0000 |
| Gemini 3 Pro (Preview) | 1M | $2 | $0.2 | $12 | $0.0000 | $0.0000 | $0.0000 | |
| Gemini 3 Flash (Preview) | 1M | $0.5 | $0.05 | $3 | $0.0000 | $0.0000 | $0.0000 | |
| Gemini 2.5 Pro | 2M | $1.25 | $0.125 | $10 | $0.0000 | $0.0000 | $0.0000 | |
| Gemini 2.5 Flash | 1M | $0.3 | $0.03 | $2.5 | $0.0000 | $0.0000 | $0.0000 | |
| Gemini 2.5 Flash-Lite | 1M | $0.1 | $0.01 | $0.4 | $0.0000 | $0.0000 | $0.0000 | |
| Gemini 2.0 Flash | 1M | $0.1 | $0.025 | $0.4 | $0.0000 | $0.0000 | $0.0000 | |
| Gemini 2.0 Flash-Lite | 1M | $0.075 | $0 | $0.3 | $0.0000 | $0.0000 | $0.0000 |