Token Counter for Local Models

Estimate how many tokens a prompt will use before you paste it into a local model. The count is calculated in your browser. It is not the official tokenizer for Llama, Mistral, Phi, or Qwen, and it can be off by roughly 10 to 15 percent. Use it to see whether a prompt is short, comfortable, or about to crowd the context window — not as a billing figure.

How the estimate is made

The page counts characters and divides by a factor that depends on the model family you pick. English prose is often near four characters per token on Llama-style BPE tokenizers. Code, JSON, and text in other scripts can be denser or sparser, which is why the result is labeled an estimate. The tool also shows character and word counts so you can sanity-check the number: a 400-word English paragraph is often in the 500 to 700 token range, not 4,000.

Phi-style tokenizers are often a bit more compact on English, so that option uses a slightly smaller divisor and the estimate comes out a little higher. Qwen is close enough to the Llama factor for a planning estimate. If you need an exact count, use the tokenizer in your runner or the model’s own tools. This page will not match that number every time.

How to use the number

  1. Paste the prompt and the document you plan to attach as text.
  2. Pick the closest model family. If you are unsure, use Llama / Mistral.
  3. Compare the estimate with the context you actually run: 4k, 8k, 16k, or whatever the model card says for your quant.
  4. Leave room for the answer. If the prompt is already 70 percent of the window, the model will cut the answer or drop the beginning of the prompt.

A practical buffer: keep the prompt under half of the context if you want a long answer, and under three quarters if you only want a short extraction. The estimate is not a promise that the runner uses the same window. Some apps reserve tokens for a system prompt you cannot see. If replies stop early, shorten the source, not just the instructions.

Worked examples

Summarize the text below in 5 bullets. Text: [if this block plus the article estimates over half your context, split the article]

What this tool will not do

Questions

Why doesn’t this match the token number in LM Studio or Ollama?

Those apps use the model’s tokenizer. This page uses a character divisor. Being within about 15 percent is expected. If you are within a few hundred tokens of the limit, trust the runner, not this estimate.

Which family should I pick for Gemma or GPT-style local models?

Use the generic or Llama estimate. The difference is smaller than the error bar of this method.

Should I count the answer too?

This box only counts what you paste. Add the answer length yourself. Five bullets are cheap. “Write 2,000 words” is not.

Can a shorter token count fix a bad answer?

Only if the failure was a full window. If the format is wrong on a short prompt, rewrite the prompt. Start with How to Write Better Prompts for Local AI Models.

Related guides and tools