LLM Token Counter and Cost Estimator

New

Count tokens and estimate API cost across models

  • 100% Free
  • Files stay private
  • Works in your browser
Try it now·LLM Token Counter and Cost Estimator

Your text

Paste a prompt or document. The token count updates as you type, entirely in your browser.

Requiredprompt, document or chat message
sets the price used
Optionaloutput tokens, for cost

Count and cost

Tokens for the text above, priced against the model you picked.

Tokens

0

GPT-4o

Characters
0
Words
0
Input cost
$0.00
Total per request
$0.00500

The same text across models

ModelProviderInputTotal per request
GPT-4oselectedOpenAI$0.00$0.00500
GPT-4o miniOpenAI$0.00$0.00030
GPT-4 TurboOpenAI$0.00$0.0150
GPT-3.5 TurboOpenAI$0.00$0.00075
o1OpenAI$0.00$0.0300
Claude 3.5 SonnetAnthropic$0.00$0.00750
Claude 3 OpusAnthropic$0.00$0.0375
Claude 3 HaikuAnthropic$0.00$0.00063
Gemini 1.5 ProGoogle$0.00$0.00250
Gemini 1.5 FlashGoogle$0.00$0.00015
Gemini 2.0 FlashGoogle$0.00$0.00020

Counts use the o200k byte pair encoder in your browser, so nothing is uploaded. That encoder is exact for current OpenAI models. Anthropic and Google do not publish a client side tokenizer, so their numbers are close estimates, usually within a few percent. Prices are list rates in US dollars per million tokens and can change, so treat the cost as a planning figure and check your provider's current pricing before you commit to a budget.

How it works

  1. Paste your text

    Paste a prompt or document into Text to measure. The count runs in your browser as you type.

  2. Choose a model

    Pick a Model to set the prices used, and optionally enter an Expected reply length in tokens.

  3. See tokens and cost

    Watch the token count and Total per request cost update as you type. Anthropic and Google counts are estimates.

The LLM Token Counter and Cost Estimator is a free browser-based tool that counts the tokens in any text and estimates what sending that text to a large language model would cost. It runs the o200k tokenizer through the gpt-tokenizer library, the same byte pair encoding that OpenAI's GPT-4o and o1 models use, so the count is exact for those models and a close estimate for others. It is built for prompt engineers, developers, and content teams who need to size a prompt and predict its price before making an API call.

At a Glance

DetailSummary
What it doesCounts tokens and estimates model cost for any text
InputPlain text or a prompt you type or paste
OutputToken count, character count, word count, and estimated cost
Runs whereEntirely in your browser
PrivacyText is never uploaded; counting happens on your device
PriceFree, no sign-up
Best forSizing prompts and budgeting API calls across models

What Is LLM Token Counter and Cost Estimator?

The LLM Token Counter and Cost Estimator turns raw text into a token count and a price estimate for popular models. When you type or paste text, it calls encode(text) from the gpt-tokenizer library and reports the length of the resulting token array. That encoder is the o200k byte pair tokenizer, which is what GPT-4o and o1 use to split text, so for those models the number is the real count they would bill against.

A grouped model menu lets you switch between OpenAI (GPT-4o, GPT-4o mini, GPT-4 Turbo, GPT-3.5 Turbo, o1), Anthropic (Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku), and Google (Gemini 1.5 Pro, Gemini 1.5 Flash, Gemini 2.0 Flash). Each model carries its published price per one million tokens, split into an input rate and an output rate. The tool multiplies your token count by the input rate, and if you add an expected output length it multiplies that by the output rate too, then sums the two into a total estimate.

How LLM Token Counter and Cost Estimator Is Different

Most token counters give you a rough guess and stop there. Many estimate tokens by dividing characters by four, which drifts badly on code, punctuation, and non-English text. This tool runs the actual o200k tokenizer, then goes further and attaches real per-model pricing so you see cost, not just count. It also runs entirely on your device, so a confidential prompt never leaves the page.

AspectThis ToolA Typical Counter
Token methodReal o200k tokenizer (gpt-tokenizer)Characters divided by four, a rough guess
CostInput plus optional output pricing per modelToken count only, no price
PrivacyRuns in your browser, nothing uploadedOften sends text to a server
Model coverageOpenAI, Anthropic, and Google side by sideUsually one model
HonestyLabels estimated versus exact countsPresents one number as fact

Who Benefits from This Tool

  • Prompt engineers: confirm a system prompt and its examples fit inside a model's context window before sending.
  • Backend developers: predict the per-request API cost of a feature while it is still being built.
  • Content teams: budget a bulk generation job before committing to a run.
  • AI product managers: compare model prices for the same workload and pick the cheapest that meets quality.
  • RAG builders: measure document chunk sizes against a context limit so retrieval stays within budget.
  • Students and researchers: see exactly how a tokenizer splits words, spaces, and symbols into tokens.

Key Features

  • Live counting: token, character, and word counts update as you type, debounced so typing stays smooth.
  • Real tokenizer: the o200k encoder via gpt-tokenizer gives an exact count for GPT-4o and o1.
  • Grouped model menu: OpenAI, Anthropic, and Google models in one dropdown with per-model pricing.
  • Input and output cost: add an expected output length to get input cost, output cost, and a total.
  • Multi-model comparison: a small table shows the estimated cost of the same text across several models.
  • Private and free: the tool runs in your browser, needs no account, and never uploads your text.

How to Use

  1. Paste or type your text or prompt into the input box.
  2. Watch the live token, character, and word counts appear.
  3. Pick a model from the grouped menu to set its pricing.
  4. Enter an expected output length (optional) to include output cost in the total.
  5. Read the token count and estimated cost, and scan the comparison table across models.
  6. Use Try Sample to load a ready paragraph if you want to see it work first.

Worked Example

Here is a realistic prompt and the exact result the tool returns for it.

FieldValue
InputWrite a 200-word product description for a stainless steel water bottle that keeps drinks cold for 24 hours. Emphasize durability, the leak-proof lid, and eco-friendly materials.
Characters178
Words26
Tokens (o200k)37
Input cost at GPT-4o (2.50 per 1M)about 0.00009
Output cost, 300 expected tokens (10.00 per 1M)0.0030
Estimated totalabout 0.0031

Notice that the 26-word prompt is 37 tokens, so word count alone would have understated the size. Notice too that the expected output dominates the cost, because output is priced higher than input for most models.

Common Use Cases

  • Checking that a system prompt plus examples fits inside a model's context window.
  • Estimating the monthly API spend of a chatbot feature before launch.
  • Comparing the cost of GPT-4o mini against Claude 3 Haiku for a summarization job.
  • Trimming a long prompt to lower the per-call price without losing meaning.
  • Sizing retrieval chunks so a RAG pipeline stays under its token budget.
  • Teaching how tokenization differs from a plain word count.

Tips and Best Practices

  • Fill in the expected output length, because output tokens usually cost more than input tokens.
  • Remember tokens are not words. In English one token is roughly four characters, or about three quarters of a word.
  • Count the full prompt, including the system message and any examples, not just the user's question.
  • Treat the count for Claude and Gemini as an estimate, since those vendors publish no official public tokenizer.
  • Multiply a single-call estimate by your request volume to project real spend across a workload.

Limitations and Notes

  • The o200k count is exact for GPT-4o and o1, very close for GPT-4 Turbo and GPT-3.5 Turbo, and an estimate for Claude and Gemini, which use their own private tokenizers.
  • Prices follow each provider's published list rate per one million tokens and can change, so verify against the provider before you commit a budget.
  • The estimate covers text tokens only. It does not count images, tool call schemas, or any cached-token discounts.
  • The cost figure is an estimate to plan with, not an invoice. Your actual bill depends on the exact model, region pricing, and usage tier your account is on.

FAQs

The token count is exact for GPT-4o and o1, because the tool uses the o200k tokenizer that those models use through the gpt-tokenizer library. It is very close for GPT-4 Turbo and GPT-3.5 Turbo, which use a related encoding, and it is a reasonable estimate for Claude and Gemini, whose vendors do not publish an official public tokenizer. The tool labels which models are exact and which are estimated.

No. All tokenizing and cost math run in your browser on your own device, so your text never leaves the page. That makes the tool safe for confidential prompts, internal documents, and unreleased content. Nothing is stored or sent to a server.

Model providers charge separate rates for the tokens you send (input) and the tokens the model generates (output), and output almost always costs more. The tool multiplies your counted tokens by the input rate and, if you enter an expected output length, multiplies that by the output rate, then adds the two. Filling in the expected output field gives you a realistic total rather than input cost alone.

A token is a chunk of text that a language model treats as a single unit, usually a short word, a word piece, or a punctuation mark. In English one token averages about four characters, or roughly three quarters of a word, though code and rare words split into more tokens. The o200k tokenizer decides these boundaries the same way GPT-4o does.

Not to the exact token, because Anthropic and Google do not release an official public tokenizer for browser use. The tool shows the o200k count for those models and clearly labels it as estimated, which is close enough for budgeting and comparison. For an exact Claude or Gemini count you would use each vendor's own API token counter.

Estimate one representative call, including its expected output length, then multiply that per-call total by how many calls you expect to make. For example, a request that costs about 0.0031 run 10,000 times projects to roughly 31 in list pricing. Adjust for prompts that vary in length by using an average call rather than a single sample.