AI

AI Token Counter

A fast AI token counter and cost estimator for the major LLM APIs — GPT-4o, GPT-4 Turbo, GPT-3.5, Claude Opus 4, Claude Sonnet 4, and Claude Haiku 4. Paste or type into the textarea and see live estimates of token count, character count, and word count, plus a per-million-token cost breakdown for input, output, and total spend. Pick a model, optionally specify expected output tokens, and get an instant budget for any prompt. Ideal for sizing up long prompts before you send them and for estimating batch-job costs without having to run them first.

Last updated: March 2026
Estimate only. Actual token counts depend on the exact tokenizer per model. For precise values, use OpenAI's tiktoken library or Anthropic's count_tokens endpoint. This tool uses the industry-standard 4-characters-per-token heuristic for English text.
Short prompt (<500) Long prompt (500-2000) Essay (2000-8000) Full article (8000+)
0
Est. Tokens
0
Characters
0
Words
0
Lines

Estimated Cost

Input (0 tokens @ $3.00/M)$0.000000
Output (0 tokens @ $15.00/M)$0.000000
Total per request$0.000000
Copied!

Frequently Asked Questions

How accurate is the 4-characters-per-token estimate?
The 4 characters/token heuristic is an approximation OpenAI publishes as a rule of thumb for English prose. Actual counts depend on the exact tokenizer — GPT-4o uses o200k_base, GPT-3.5 and GPT-4 Turbo use cl100k_base, and Claude uses Anthropic's proprietary BPE tokenizer. Expect accuracy within 10–15% for typical English text. Code, JSON, non-English languages, unusual punctuation, and long unique identifiers can all produce counts that differ by 30% or more from the estimate.
How do I get exact token counts?
For OpenAI models, install the tiktoken Python library (pip install tiktoken) and call encoding_for_model("gpt-4o") to get the exact tokenizer. For Anthropic, use the count_tokens endpoint on the Messages API which returns exact token counts without consuming quota. For JavaScript/Node, gpt-tokenizer and @anthropic-ai/tokenizer provide client-side equivalents. Run these in your prompt pipeline before calling the API if precise counting matters for your budget.
Why does the same text count differently across models?
Each model family uses a different tokenizer. GPT-3.5 and GPT-4 Turbo use cl100k_base (100,277 tokens), GPT-4o uses the newer o200k_base (200,019 tokens) which is roughly 20% more efficient on many non-English languages, and Claude uses its own BPE variant. The same sentence can produce different token counts across providers, which affects both cost (billed per token) and context window usage (tokens consumed against the model's max context).
What are input tokens vs output tokens?
Input tokens are everything you send to the model: the system prompt, user message, prior conversation history, and any tool-call schemas. Output tokens are what the model generates in response. Output tokens are almost always priced 3–5× higher than input, because autoregressive generation is more computationally expensive than prefill. This is why strategies like limiting max_tokens, requesting terse responses, and caching long system prompts have an outsized effect on cost.
How do I reduce my AI API costs?
Four main strategies: (1) Use smaller models for simple tasks — Haiku or GPT-4o-mini handle most classification and extraction jobs as well as their larger siblings at 10× lower cost; (2) Enable prompt caching to reuse repeated system prompts at up to 90% discount (both OpenAI and Anthropic support this); (3) Trim conversation history so you're not re-sending the whole transcript every turn; (4) Use the Batch API for non-urgent workloads — 50% discount on OpenAI, similar on Anthropic. Careful prompt engineering to strip unnecessary context is the single biggest lever in most apps.
Are the prices on this page current?
The prices are illustrative values reflecting published rates as of January 2026: GPT-4o at $2.50/$10, GPT-4 Turbo at $10/$30, GPT-3.5 at $0.50/$1.50, Claude Opus 4 at $15/$75, Claude Sonnet 4 at $3/$15, and Claude Haiku 4 at $1/$5 per million input/output tokens respectively. Providers adjust pricing periodically — always check OpenAI's and Anthropic's pricing pages before committing to a cost model for a production budget.