████████ ██████ ██ ██ ███████ ███ ██ ███████
██ ██ ██ ██ ██ ██ ████ ██ ██
██ ██ ██ █████ █████ ██ ██ ██ ███████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██████ ██ ██ ███████ ██ ████ ███████
LLM Token Counter & Cost Calculator
Count exact tokens for GPT-4o / GPT-4.1 / o-series (real tiktoken) and estimate Claude, Gemini, Llama, Mistral & DeepSeek. See context-window usage and API cost — 100% in your browser, your prompt never leaves the page.
| Model▾ | Tokens▾ | % of window▾ | Input cost▾ |
|---|
OpenAI counts (GPT-4o, GPT-4.1, o-series, GPT-4, GPT-3.5) are exact via in-browser tiktoken. All other models are calibrated estimates (typically within ~10%). Pricing is illustrative, in USD per 1M tokens, as of June 2026 — always verify current rates with each provider. Click a column header to sort, or a row to select that model above.
LLM Pricing & Context Window Comparison
Quick reference for the token limits and API pricing used by this calculator. Prices are in USD per 1 million tokens and are illustrative as of June 2026 — always confirm current rates with each provider. OpenAI token counts are exact (real tiktoken); other models use calibrated estimates.
| Model | Vendor | Context window | Input $/1M | Output $/1M | Token count |
|---|---|---|---|---|---|
| GPT-4o | OpenAI | 128K | $2.5 | $10 | Exact (tiktoken) |
| GPT-4o mini | OpenAI | 128K | $0.15 | $0.60 | Exact (tiktoken) |
| GPT-4.1 | OpenAI | 1M | $2.0 | $8.0 | Exact (tiktoken) |
| o3 | OpenAI | 200K | $2.0 | $8.0 | Exact (tiktoken) |
| GPT-3.5 Turbo | OpenAI | 16K | $0.50 | $1.50 | Exact (tiktoken) |
| Claude Opus 4 | Anthropic | 200K | $15 | $75 | Estimate |
| Claude Sonnet 4 | Anthropic | 200K | $3 | $15 | Estimate |
| Claude Haiku | Anthropic | 200K | $0.80 | $4 | Estimate |
| Gemini 2.5 Pro | 1M | $1.25 | $10 | Estimate | |
| Gemini 2.5 Flash | 1M | $0.30 | $2.50 | Estimate | |
| Llama 3.1 405B | Meta | 128K | $0.90 | $0.90 | Estimate |
| Mistral Large | Mistral | 128K | $2 | $6 | Estimate |
| DeepSeek V3 | DeepSeek | 128K | $0.27 | $1.10 | Estimate |
LLM Token Counter & Cost Calculator — frequently asked questions
What does this tool do?
Paste, type, or upload text and it counts how many tokens that text costs across 13 major LLMs — GPT-4o, GPT-4.1, o3 and GPT-3.5 with an exact in-browser tokenizer, plus calibrated estimates for Claude, Gemini, Llama, Mistral and DeepSeek. It also shows context-window usage, per-request API cost, and a monthly cost projection.
Is my text sent to a server?
No. Tokenization and all cost math run entirely client-side, in JavaScript, in your browser. Your prompt never leaves the page — safe for proprietary prompts, customer data, or anything else you can't paste into a public API.
Is it free?
Yes, completely free, no signup, no account, no ads, no usage limit. One of the free client-side browser tools at jasperbernaers.com.
What is a token?
A token is the unit an LLM actually reads and is billed on — not a word, not a character. Common English words are often a single token, less common words split into two or more sub-word pieces ("tokenization" might become "token" + "ization"), and a single emoji or unusual Unicode character can cost several tokens. That mismatch between what you type and what you're billed for is the whole reason a token counter is useful.
What is a context window?
The maximum number of tokens a model can process in a single request, input and output combined. The gauge under the token count shows what percentage of the selected model's window your current text uses.
How are tokens counted for OpenAI models?
GPT-4o, GPT-4.1 and o-series use o200k_base; GPT-4 and GPT-3.5 use cl100k_base — the real tiktoken byte-pair encoders, loaded and run in your browser. These counts are exact, matching what the OpenAI API actually charges.
Are Claude and Gemini counts exact?
No — Anthropic and Google don't publish a browser-usable tokenizer, so Claude, Gemini, Llama, Mistral and DeepSeek counts are calibrated estimates (usually within about 10%), clearly labelled as estimates rather than exact counts throughout the tool.
Why do different models count the same text differently?
Each vendor trains its own tokenizer on its own data, so the vocabulary of sub-word pieces differs. The same sentence can be 42 tokens for one model's tokenizer and 51 for another's, purely because they split words at different points. This is also why swapping models can change your effective context budget even if the text is identical.
Why does my count differ from ChatGPT's usage page or another tool?
A few common reasons: you're comparing an exact GPT count against another tool's estimate (or vice versa); the other tool is counting a different model's tokenizer; your actual API call includes extra tokens this page doesn't see, like a system prompt, chat-formatting overhead, or tool/function definitions; or the other tool is simply out of date. For OpenAI models, this tool's counts use the same tiktoken library OpenAI itself publishes, so they should match exactly for the same raw text.
What happens if my text exceeds the context window?
The gauge turns yellow past 80% and red once you're over 100%. In practice, exceeding a model's context window means the API call fails outright or the provider silently truncates the oldest content — neither is what you want, so treat red as a hard stop rather than a warning.
How is API cost calculated?
Input cost = (token count ÷ 1,000,000) × the model's input price per million tokens. Output is billed separately at the model's output price per million tokens, which this tool adds using your estimated output length. Prices shown are illustrative and dated — always verify current pricing directly with each provider before budgeting off them.
Why is output more expensive than input?
Generating new tokens is more computationally expensive than reading existing ones, so every major provider prices output at roughly 3–5× the input rate (some go higher). This is exactly why the total-cost figure below the token count factors in your estimated output length rather than only counting input.
What does the monthly cost projector calculate?
It takes the total cost of one request (your current input tokens plus your estimated output tokens, at the selected model's prices) and multiplies it by the requests/day figure you enter, then by 30 for a monthly estimate. It's a quick way to sanity-check whether a prompt design is affordable at production volume before you build around it.
Do system prompts and chat history count toward tokens?
Yes. Every message sent to the API counts — the system prompt, all prior user and assistant turns you resend for context, tool/function definitions, and the new user message. In a multi-turn chat app, the running conversation is usually resent in full on every call, so token (and cost) usage grows with conversation length unless you actively trim or summarize history.
Does prompt caching change the cost?
Where a provider offers it, yes — repeated, unchanged prefixes (like a long system prompt or a fixed set of few-shot examples) can be cached and billed at a steep discount on subsequent calls, often 50–90% off the normal input rate. This tool calculates the standard, non-cached rate; if you're using prompt caching in production, your real cost will usually be lower than what's shown here.
Can I upload a file instead of pasting text?
Yes. Click Upload file or drag a plain-text file (.txt, .md, .json, .csv, code files, and similar) straight onto the text box. It's read locally with the browser's File API — nothing is uploaded anywhere.
What does "Highlight tokens" show?
It renders your text with alternating colour bands around each individual token, so you can see exactly where the tokenizer splits words apart — the same idea as OpenAI's official tokenizer playground. It only works for models with an exact tokenizer (the GPT/o-series family); for estimate-only models there's nothing exact to visualize, so the button stays disabled until you pick a GPT model. Very long inputs are shown truncated for performance.
Can I link directly to a token count?
Yes. Use ?text=Hello%20world&model=gpt-4o and the page opens with the text already counted. Supported parameters: text (aliases t, q, prompt) and model. The address bar stays in sync for short inputs, so AI agents and scripts can deep-link straight to a count.
Does it remember what I've counted before?
Yes. Open the History tab above the comparison table to see recently counted texts, saved only in your browser's local storage. Click an entry to restore that text and model, or clear the list anytime.
Can I export the comparison table?
Yes. Use Copy as Markdown to get a ready-to-paste Markdown table (handy for a PR description or a ticket), or Download CSV to get a spreadsheet-ready file with every model, its token count, percentage of context window, and input cost for your current text.