TextSorter
AI Developer Tool

LLM Prompt Token Counter & Cost Calculator

Real-time token counting, visual token boundary breakdown, and multi-model cost analysis across GPT-4o, Claude Opus 5, DeepSeek R1, and Gemini 2.0.

Estimated Tokens
0
GPT-4o (o200k)
Characters & Words
0
0 words • 0.0 chars/tok
Est. Prompt Cost
$0.000000
Input pricing, estimated count
Context Window (128k)
0.00%
0 tokens

How This Counter Actually Turns Your Text Into a Number

Short version: nothing here runs a real vendor tokenizer. The tool walks your text with a pattern that splits it the way modern subword tokenizers do, contractions, runs of letters, runs of digits, runs of punctuation, and whitespace, then scales the result for whichever model you have selected. Every count on this page is labeled estimated because it is one.

You paste
It's a 200k context window.
Boundaries the estimator finds
It | 's | a | 200 | k | context | window | .

Eight boundaries come out of that ten-word sentence, and two of them are worth noticing. It's splits into It and 's, because the pattern checks for a short list of English contractions before it tries to match a plain run of letters. And 200k splits into 200 and k, because a run of digits and a run of letters are two different categories to this pattern even when nothing separates them. Neither split is a mistake. It is exactly how the estimator is built, and it is close to how production subword tokenizers handle the same input, which is why a shorthand like a number followed by a lowercase k quietly costs two tokens instead of one.

The character count next to the token count is not a separate measurement. It is your text's length in characters divided by whichever token count is currently on screen, which means switching the model dropdown changes the reported chars-per-token figure even though you have not touched the text. That number moves because the token count underneath it moves.

The "words" figure just to the left of the character count is a different measurement again. It comes from splitting your text on whitespace, not from the boundary pattern at all, so a hyphenated compound or a long URL counts as a single word there even though the token boundaries inside it might be several. Words, characters and tokens are three separate counts on this page, and they only ever agree by coincidence.

This will not match your bill. Treat the number as a calibrated estimate for planning a prompt, not as the figure that will appear on an invoice. When exact billing tokens matter, run the same text through the provider's own tokenizer or read the token usage the API response returns.

Why the Same Text Reports a Different Token Count Per Model

The boundaries do not change, the multiplier does. Every model in the dropdown starts from the same raw count, then gets scaled by a factor tied to its vendor, because a pattern shaped around GPT-style tokenization does not split every other vendor's text the same way it splits its own.

Vendor familyMultiplier appliedModels it covers here
OpenAI1.00 (baseline)GPT-4o, GPT-4o Mini, o3-mini, o1, GPT-4 Turbo
Anthropic1.18Claude Fable 5, Claude Opus 5, Claude Sonnet 5, Claude Haiku 4.5
Google1.05Gemini 2.0 Flash, Gemini 2.0 Flash Thinking, Gemini 1.5 Pro, Gemini 1.5 Flash
DeepSeek1.05DeepSeek R1, DeepSeek V3
Meta1.10Llama 3.3 70B
Alibaba1.10Qwen 2.5 72B
Mistral1.10Mistral Large 2
Raw boundary count
250
Displayed for GPT-4o vs Claude Opus 5
250 tokens (GPT-4o)
295 tokens (Claude Opus 5)

The 1.18 figure attached to Anthropic's models exists because a GPT-shaped boundary pattern tends to undercount how Claude's own tokenizer splits ordinary prose, by roughly fifteen to twenty percent, and by more once the text turns into code or moves away from English. Google and DeepSeek sit much closer to the baseline at 1.05, and the open-weight families land at 1.10. None of these numbers come from running the actual vendor tokenizer against your text. They come from a fixed multiplier assigned once per vendor family, applied the same way to every prompt that vendor's models see here.

The multiplier is chosen by vendor, not by the language of your prompt. Switching from an English paragraph to a Japanese one does not change which multiplier gets applied to a given model, even though the real gap between a GPT-shaped estimate and that model's true tokenizer is not constant across languages.

How the Estimate Turns Into a Dollar Figure

Input and output are priced and shown separately, on purpose. The cost you see for your prompt only covers the tokens you typed. Anything the model would generate in reply is a second, independently priced number driven by the Projected Completion Tokens slider.

The primary "Est. Prompt Cost" card multiplies the adjusted token count for your selected model by that model's input price per million tokens, and shows six decimal places because prompt costs at everyday lengths land well under a cent. The Multi-Model Cost Matrix in the sidebar does the same input math for every model in the catalog at once, then adds a second number: your projected output tokens, which default to 1,000 and can be dragged anywhere from 0 to 8,000, multiplied by that model's separate output price per million.

1,000 input tokens on GPT-4o
Prompt cost: $0.002500
Plus 1,000 projected output tokens
Output cost: $0.010000
Total: $0.012500

Every row in the Multi-Model Cost Matrix reprices your prompt from scratch rather than reusing the token count shown for your selected model. Each row runs the same raw boundary count back through the same per-vendor scaling described above, using its own model's vendor family, so a Claude row and a Gemini row in the same table can show different token counts for the identical text you pasted, not just different prices for the same count.

That four-to-one gap between input and output pricing on GPT-4o is not unusual. It shows up across almost every model in the catalog: Claude's models charge five times as much to generate a token as to read one, Gemini and DeepSeek sit around four times, and Mistral Large 2 sits around three times. The open-weight entries, Llama 3.3 70B and Qwen 2.5 72B, are the exception, with output priced barely above input. Reading only the sidebar's "Prompt Cost" column and ignoring "Total" hides most of the real cost difference on any prompt where the model is expected to write more than a short reply.

Set the slider to match the job. A short classification or extraction prompt might realistically produce fifty output tokens. A long-form drafting or code-generation prompt might produce two thousand or more. Moving the slider before comparing models gives a Total column that reflects the actual task instead of the default guess.

What the Context Window Bar Is Measuring

It is your estimated token count divided by the selected model's own context window, nothing more. That window is read from the catalog entry for whichever model you have chosen, and it is not the same number twice as you switch models.

The catalog's context windows span a wide range: DeepSeek's two models are the smallest at 64,000 tokens, most of the OpenAI and open-weight models sit at 128,000 or 200,000, several Claude and Gemini models reach a full 1,000,000, and Gemini 1.5 Pro tops the list at 2,000,000. A prompt that barely registers against the largest window can be most of the way to the limit on the smallest one.

50,000 estimated tokens on DeepSeek R1 (64k window)
Just over 78% used
About 14,000 tokens left
The same 50,000 tokens on Gemini 1.5 Pro (2M window)
2.5% used
About 1,950,000 tokens left

The percentage bar is visually capped at 100%, so a full bar only tells you the prompt has reached or passed the limit, not by how much. A prompt at 105% of a model's window and a prompt at 300% of it both render as a completely full bar. If a prompt is close to a model's window, check the actual token count and the window size in the label above the bar rather than judging distance from the limit by how full the bar looks.

A bigger context window changes how much of it your prompt fills. It does not change what your prompt costs. Cost is still the token count times the price per token, so moving to a model with a much larger window to fit more text only helps you avoid truncation, not avoid paying for what you send.

Why Code and Non-Latin Text Do Not Behave Like English Prose Here

The boundary pattern groups characters by category, not by meaning. A run of letters becomes one boundary no matter how long that run is or what language it is written in, and that single rule is responsible for most of the surprises you will see outside plain English sentences.

Four English words, space separated
blue sky today now
Boundaries found
4 (blue, sky, today, now)
Four Chinese characters, no spaces
阳光正好
Boundaries found
1 (one unbroken letter run)

Those two examples are visually similar in length and both are made of letters as far as the pattern is concerned, but English separates its words with spaces and Chinese does not, so the letter-run rule sweeps the entire unspaced phrase into a single boundary. Real subword tokenizers spend far closer to one token per character on dense, unspaced scripts like Chinese and Japanese, so this estimator's count on that kind of text should be read as a rough lower bound, not a real figure, and the per-vendor multiplier described earlier does nothing to correct it, since that multiplier is applied by model family rather than by the language it detects.

The same category rule cuts the other way on long numbers and dense punctuation. A run of digits becomes one boundary regardless of how many digits are in it, so a ten-digit reference number counts the same as a single-digit one. A run of adjacent symbols becomes one boundary too, as long as nothing interrupts it, which is common in minified code and compact JSON: brackets, semicolons and arrows chained together with no letters or spaces between them collapse into a single piece here, where a production tokenizer more often splits that same run into several individual symbol tokens. Whitespace is the one category this estimator treats close to how real tokenizers do: indentation, blank lines and trailing spaces each register as their own boundary, so heavily formatted code and prompts padded with extra blank lines genuinely do cost more, on this counter and on the model you eventually send them to.

What to Trim First, Based on the Math Above

Cut the expected reply length before you cut the prompt

Across most of the catalog, generating a token costs several times more than reading one: roughly five times on Claude's models, roughly four times on GPT-4o, Gemini and DeepSeek, and roughly three times on Mistral Large 2. The open-weight entries, Llama 3.3 70B and Qwen 2.5 72B, are the exception, with output priced only slightly above input. Given that spread, asking a model to answer in three sentences instead of three paragraphs usually saves more than trimming an equivalent number of words from the prompt itself, unless you are sending the same short prompt at very high volume.

Strip decorative punctuation

ASCII dividers, repeated dashes or equals signs used as section breaks, and boxed comment banners in code each become their own punctuation boundaries under the rules described above. None of that formatting changes what the model reads as instructions, so removing it before you paste lowers the token count without losing anything the model would have used.

Minify structured data before pasting it

Pretty-printed JSON or YAML carries indentation and line breaks that this estimator counts as real boundaries, the same way a production tokenizer does. Collapsing a payload to its compact form before including it in a prompt removes that whitespace and often merges scattered punctuation into fewer, denser runs as well.

Pick a context window that fits the job, not the biggest one available

Since the catalog's windows run from 64,000 tokens up to 2,000,000, the same reference document can look nearly full on one model and barely noticeable on another. Check the percentage bar for the model you actually intend to use rather than assuming a large window on a different model tells you anything about the one you picked.

Use Visual Tokens to find where the count is coming from

Switching to the Visual Tokens view color-codes every boundary the estimator found and shows each one's position and character length on hover. Scanning that view over a long prompt is a faster way to spot repeated formatting or punctuation-heavy sections eating into your count than reading the single number at the top of the page.

Frequently Asked Questions

Does this tool use a real tokenizer like OpenAI's tiktoken?
No. It estimates boundaries with a pattern that mimics how BPE tokenizers split contractions, letter runs, digit runs and punctuation, then scales the result with a per-vendor multiplier. Every number on this page is labeled estimated for that reason, and if you need an exact count for billing, use the provider's own tokenizer or API response.
Why does switching the model dropdown change the token count without editing my text?
The raw boundary count from the shared pattern stays the same. What changes is the multiplier applied afterward: GPT models use a 1.00 baseline, Claude models use 1.18, Google and DeepSeek use 1.05, and Meta, Alibaba and Mistral use 1.10, because a GPT-shaped pattern undercounts how the other tokenizers actually split ordinary prose.
Is my prompt sent anywhere when I use this tool?
No. Tokenization, cost math, and the context window gauge all run in your browser with JavaScript. Nothing you paste is uploaded, logged or stored on a server.
What is the difference between the Prompt Cost and Total columns in the cost matrix?
Prompt Cost only covers the tokens in your input, priced at each model's input rate. Total adds the projected completion cost on top, using the Projected Completion Tokens slider and each model's separate output rate, since every model in the catalog charges a different price for generating tokens than for reading them.
Why is the output rate so much higher than the input rate for most models?
Generating a token requires a full forward pass through the model for every token produced, while reading a prompt can be processed in parallel. Across the catalog, output pricing runs roughly two to five times the input price for most models, and this tool's cost table applies both rates separately rather than blending them into one number.
What does the context window percentage actually measure?
It divides the estimated token count for your prompt by the context window of whichever model is selected, which ranges from 64,000 tokens for DeepSeek's models up to 2,000,000 for Gemini 1.5 Pro in this catalog. The bar visually caps at 100 percent, so a full bar can mean your prompt is slightly over the limit or dramatically over it, not just barely fitting.
Will this tool give an accurate count for Chinese, Japanese or other non-Latin text?
Treat it as a rough lower bound, not a match. The boundary pattern groups any unbroken run of letters into a single piece regardless of language, so a run of Chinese or Japanese characters with no spaces between them can be counted as one boundary even though a production tokenizer typically spends close to a token per character on that kind of text. The per-vendor multiplier does not correct for this because it is applied by model family, not by detected language.
Why does pasting code often produce a token count that feels too low?
The same boundary pattern groups any run of adjacent symbols, such as brackets, semicolons or arrows, into a single piece as long as nothing interrupts it. Dense, minified code and deeply nested JSON chain a lot of punctuation together, which this estimator collapses into fewer boundaries than a production tokenizer, which more often splits symbols individually or in small pairs.
What does the Visual Tokens view show me?
Switching to Visual Tokens re-renders your prompt as color-coded chips, one per boundary the estimator found, cycling through five colors. Hovering over any chip shows its position in the sequence and its character length, which is a fast way to see exactly where formatting, punctuation or whitespace is adding to your count.
Does the Sample Prompt button show me a typical prompt?
It loads one fixed example, a system-prompt-style instruction about optimizing token usage in a TypeScript project, so you can see the counter, the cost matrix and the context gauge react to real text without having to write or paste anything first.

Understanding LLM Tokens and Context Costs

Large Language Models (LLMs) do not read text letter by letter or word by word. Instead, they process sequences of tokens, which are chunks of characters representing common character combinations, words, numbers, or punctuation.

Understanding your exact token count is crucial for optimizing system prompts, preventing context window overflow, and reducing API costs across production applications.

Tokenization Comparison Across Top Models

Model Family Tokenizer Encoding Average Chars / Token Input Cost (per 1M)
GPT-4o / GPT-4o Mini o200k_base (200k vocabulary) ~4.4 $2.50 / $0.15
o3-mini / o1 o200k_base Reasoning ~4.4 $1.10 / $15.00
Claude Opus 5 / Sonnet 5 Claude Byte-Pair Encoder ~4.0 $5.00 / $3.00
DeepSeek R1 / V3 DeepSeek 128k Multi-head BPE ~4.2 $0.55 / $0.14
Gemini 2.0 Flash / 1.5 Pro SentencePiece / 256k vocab ~4.2 $0.10 / $1.25
Llama 3.3 70B / Qwen 2.5 72B Tiktoken 128k / 152k Vocab ~4.3 $0.59 / $0.35