How to use the Prompt Token Counter
1. Select your AI model — this sets the context window and pricing used for estimates.
2. Type or paste your system prompt and user message into the text areas.
3. Token counts and cost estimates update in real time as you type.
What is it?
AI models process text as tokens — subword units averaging 4 characters for English text. Knowing your token count before sending an API request helps you avoid hitting context limits and estimate costs. 100 tokens ≈ 75 English words. Code and non-English text use more tokens per word.
Cost differences between models are dramatic: GPT-4o mini processes tokens at about 30× lower cost than GPT-4 Turbo, making model selection the single biggest cost lever in AI applications. This tool uses the standard 4-chars/token approximation — for exact counts use the tiktoken library.
Example
System: You are a helpful assistant. (~7 tokens) User: Explain transformers in simple terms. (~7 tokens)
Total input tokens: ~14 Context used: 0.01% of 128k Estimated input cost: $0.000070 GPT-4o pricing: Input: $0.0050 / 1K tokens Output: $0.0150 / 1K tokens
Estimates use the 4-chars/token approximation. For exact GPT counts use tiktoken (pip install tiktoken).
Benefits
Estimate API cost before running a prompt at scale
Token counts map directly to API billing — measure before deploying to avoid unexpected costs when a feature goes to production.
Identify prompts approaching context window limits
Models truncate or fail silently when context is exceeded — check token count before sending to avoid losing the end of your prompt.
Compare token efficiency across prompt formulations
Shorter prompts that achieve the same output cost less and process faster — count before committing to a prompt structure.
Budget tokens across system prompt, user message, and few-shot examples
See exactly how many tokens each section consumes to balance context window allocation across prompt components.
Frequently asked questions
Why does my count differ from OpenAI's exact count?
This tool uses the 4-chars/token approximation — the same rule of thumb used in OpenAI's documentation. Actual tokenization uses Byte-Pair Encoding (BPE) which varies by word. Code and non-English text are often under-estimated by this approximation. Use tiktoken for exact counts.
What counts toward input tokens?
All input tokens are billed at the input rate: system prompt + user messages + any tool/function definitions + conversation history in multi-turn chats. Only the model's response is billed at the output rate.
What is a context window?
The context window is the maximum number of tokens the model can process in a single API call — both input and output combined. If your prompt plus expected response exceeds the context window, the API will return an error.