AI Token Counter
See exactly how many tokens your prompt costs — with a real GPT tokenizer, not a guess.
Also known as: GPT token counter, OpenAI tokenizer, Prompt token calculator, LLM token counter
How it works
- 1Paste or type the text you want to count.
- 2Pick a model to feature — GPT-4o, GPT-4, GPT-3.5, Claude, or Gemini.
- 3Review the exact (or estimated) token count and how much of that model's context window it uses.
- 4Optionally enter your provider's current pricing to estimate the API cost.
Why use AI Token Counter
The real OpenAI tokenizer, not a guess
GPT-4o, GPT-4, and GPT-3.5 counts use js-tiktoken — a JS port of OpenAI's own tiktoken library — so the number matches what the API actually charges.
Compares every major model at once
See token counts and context-window usage for OpenAI, Anthropic, and Google models side by side in one table.
Visualizes actual token boundaries
Color-coded highlighting shows exactly where your text splits into tokens, not just a final count.
Honest about what's exact vs. estimated
GPT counts are labeled Exact; Claude and Gemini are labeled Estimate, since neither publishes a public tokenizer.
Cost calculator with no stale pricing baked in
You enter today's per-million-token price yourself, so the estimate never silently uses outdated numbers.
Nothing ever transmitted
Tokenization and every calculation run entirely in your browser tab.
Who uses AI Token Counter
Checking a prompt fits a model's context window
Confirm a long prompt, document, or conversation history stays under a specific model's token limit before sending it.
Estimating API cost before running a batch job
Count tokens across sample requests and use the cost calculator to project spend before scaling up.
Comparing token efficiency across models
See how the same text tokenizes differently across GPT-4o, GPT-4, and GPT-3.5 to understand cost tradeoffs.
Debugging unexpectedly high token usage
Use the token visualizer to see exactly which parts of a prompt (code, unusual words, non-English text) are consuming more tokens than expected.
Sizing a RAG chunk or embedding batch
Check how many tokens a document chunk uses before sending it to an embeddings API with its own token limits.
Trimming a prompt to fit a budget
Iteratively edit text while watching the live token count to fit a specific cost or context-window target.
About AI Token Counter
Every AI model doesn't read text as words or characters — it reads it as tokens, chunks produced by a specific tokenizer that OpenAI, Anthropic, and Google each define differently for their own models. That's why the same sentence can cost a meaningfully different number of tokens depending on which model you're asking, and why "just estimate 4 characters per token" only gets you in the right neighborhood, not an exact answer.
For OpenAI's models, this tool doesn't estimate — it runs the actual tokenizer. GPT-4o and GPT-4o mini use the o200k_base encoding; GPT-4, GPT-4 Turbo, and GPT-3.5 Turbo use cl100k_base. Both are loaded via js-tiktoken, a JavaScript port of OpenAI's own open-source tiktoken library, so the token count you see here is the same count the OpenAI API would actually charge you for.
Anthropic and Google don't publish a browser-usable tokenizer for Claude or Gemini, so those figures are clearly labeled as an estimate (roughly 4 characters per token, the standard rule-of-thumb figure for English text) rather than presented as if they were exact — a real, if unglamorous, limitation worth being upfront about rather than quietly guessing and calling it precise.
The token visualizer breaks your text into its actual token boundaries with alternating highlight colors, so you can see directly why a chunk of text costs more or fewer tokens than you'd expect — repeated words often collapse into a single token, while unusual words, code, or non-English text frequently split into several. The cost calculator deliberately doesn't pre-fill any pricing, since provider rates change often; you enter the current per-million-token price yourself and it does the math.
AI Token Counter vs. other options
How Open Tools Library compares to desktop software and other online tools.
| Feature | Open Tools Library | Desktop software | Other online tools |
|---|---|---|---|
| Price | Free, unlimited | N/A | Often free with limits |
| Tokenizer accuracy | Real OpenAI tiktoken port for GPT models | N/A | Often a rough character-based guess |
| Multi-model comparison | 10 models side by side | N/A | Usually one model at a time |
| Token visualization | Color-coded token boundaries | N/A | Rarely offered |
| Cost estimate freshness | You enter current pricing — never stale | N/A | Often hardcoded and outdated |
| Content privacy | Never leaves your device | N/A | Often uploaded to a server |
Pro tips
- GPT-4o and GPT-4o mini share the o200k_base tokenizer, so they'll always show the same token count for the same text — only their pricing and context window differ.
- Code, non-English text, and unusual proper nouns typically use more tokens per character than plain English prose, since the tokenizer's vocabulary is trained mostly on common English patterns.
- The cost calculator's output-token field is for the response you expect back, not the input — leave it at 0 to estimate input cost alone.
- Claude and Gemini figures are approximate by necessity; if you need an exact Claude count, the closest option is checking token usage directly in that provider's own API response.
Technical specs
- Exact tokenizers
- cl100k_base (GPT-4/GPT-3.5), o200k_base (GPT-4o) via js-tiktoken
- Estimated models
- Claude 3.5/3, Gemini 1.5 (~4 characters per token)
- Models compared
- 10 models across OpenAI, Anthropic, and Google
- Token visualizer
- Available for exact (GPT-family) tokenizers
- Cost calculator
- User-entered pricing — nothing pre-filled or hardcoded
- Processing location
- 100% local, in your browser
Privacy & security
A tool for checking how much a prompt costs shouldn't itself require sending that prompt to a server to find out.
Tokenization runs entirely in your browser — your text is never uploaded, never seen by a server.
No account, no email, no login — just text in, a token count out.
The cost calculator uses only the numbers you type in; nothing is looked up or transmitted.
Equally private whether you're checking a short prompt or a long document.
Frequently asked questions
Is the GPT token count actually exact?
Yes — it uses js-tiktoken, a JavaScript port of OpenAI's own open-source tiktoken library, running the same BPE tokenizer OpenAI's API uses to bill your requests.
Is my text uploaded anywhere?
No. Every calculation, including tokenization, runs entirely in your browser — nothing is ever transmitted.
Why can't this tool give an exact Claude or Gemini token count?
Anthropic and Google haven't published a tokenizer that can run in a browser, unlike OpenAI's open-source tiktoken. The Claude/Gemini figures are a clearly labeled estimate, not an exact count.
Does the cost calculator use live, current pricing?
No prices are built in at all — you enter your provider's current per-million-token rate yourself, so the estimate is never silently based on outdated numbers.
What's the difference between cl100k_base and o200k_base?
They're OpenAI's two most recent tokenizer encodings — cl100k_base powers GPT-3.5 Turbo and GPT-4, while o200k_base (a larger vocabulary) powers GPT-4o and GPT-4o mini.
Is there a text length limit?
No hard limit — very long text just takes a little longer to tokenize since everything runs on your device.
Troubleshooting
Why do GPT-4o and GPT-4 show different token counts for the same text?
They use different tokenizer encodings — GPT-4o uses o200k_base, while GPT-4 uses cl100k_base. Different vocabularies mean the same text can split into a different number of tokens.
Why is the Claude or Gemini count labeled an estimate?
Anthropic and Google don't publish a browser-usable tokenizer for their models, so this tool uses the standard ~4-characters-per-token approximation for those rows instead of pretending to an exact count it can't produce.
The token visualizer isn't showing
It only appears for models with an exact tokenizer (the GPT family) — switch the featured model to GPT-4o, GPT-4, or GPT-3.5 to see it.
My estimated cost seems off
Double check the price you entered is per 1,000,000 tokens (not per 1,000), and that it matches the current rate on your provider's pricing page — nothing here is pre-filled, by design.
Related searches
Landed here looking for something worded a little differently? AI Token Counter covers all of these too:
Ready to use AI Token Counter?
Free, private, and ready right now — no signup required.
Scroll to AI Token Counter