Home / Tools / LLM Token Counter
Free tool · runs in your browser

LLM Token Counter

Estimate how many tokens a prompt uses, how much of a model's context window that fills, and what a request would cost at prices you enter. Your prompt is never uploaded — which matters, because pasting a real prompt into a remote token counter means sending it to someone else.

This is an estimate, not an exact count. See the explanation below for how close it gets and when to use the provider's own counter instead. Prices are whatever you type — this page ships no price list, because published prices change and a stale number is worse than none.

How it works

What a token is

Models don't read characters or words — they read tokens, produced by a subword tokenizer. Common words are usually a single token; rarer words split into pieces; whitespace and punctuation are tokens too.

Useful rules of thumb for English: about 4 characters per token, or roughly 0.75 words per token. Code is denser in tokens than prose because punctuation, indentation and identifiers fragment more. Non-English text, especially CJK, can be far denser — sometimes one token per character.

How accurate this estimate is, and why it is an estimate

An exact count needs the model's own tokenizer and vocabulary file, which is megabytes of data and differs per model family — GPT's cl100k/o200k, Claude's tokenizer, Llama's SentencePiece model all give different numbers for the same text.

This tool uses a heuristic: it splits on the boundaries real tokenizers mostly agree on — word boundaries, punctuation, whitespace runs, CJK per character — and breaks long words into roughly four-character subwords. Expect to land within about 10–15% for English prose and code.

That is accurate enough for budgeting and for checking whether a prompt fits a context window. It is not accurate enough for billing reconciliation or for a hard limit you must not cross. For an exact figure, use the provider's own tokenizer or the token count their API returns.

Why pasting prompts into online counters is a bad habit

A prompt is often the most sensitive thing in an AI application: it contains your system instructions, sometimes customer data, sometimes proprietary context. Most online token counters post it to a server to tokenize it.

This page does the estimate locally. Nothing is uploaded, so you can measure a real production prompt without disclosing it.

What people use it for

  • Checking a prompt fits inside a model's context window before you send it.
  • Budgeting a feature — estimate cost per request and multiply by expected volume.
  • Comparing two prompt drafts to see which is cheaper to run at scale.
  • Deciding whether to truncate or summarise context before including it.
  • Sanity-checking a bill that came in higher than expected.

Nothing is uploaded. This tool runs entirely in JavaScript in your browser. Your input is never sent to a server, never logged and never stored, and no account is required. Once the page has loaded you can go offline and it still works — open your browser's network tab and watch if you'd like to confirm it.

Frequently asked questions

How accurate is the token estimate?

Within roughly 10-15% for English prose and code. It is a heuristic, not a real BPE tokenizer, because an exact count requires each model's own multi-megabyte vocabulary file. Good enough for budgeting and context-window checks; not good enough for billing reconciliation.

Why doesn't the page list model prices?

Because published prices change, and a stale price shown as fact is worse than no price at all. You enter the current prices from your provider's pricing page and the tool does the arithmetic.

How many characters are in a token?

About 4 for English prose, or roughly 0.75 words per token. Code is denser because punctuation and indentation fragment into more tokens. CJK text can approach one token per character.

Do different models count tokens differently?

Yes. GPT, Claude and Llama use different tokenizers and give different counts for identical text. Treat any single estimate as approximate across model families.

Is my prompt uploaded?

No, and that is the main reason to use this page. The estimate runs in your browser, so you can measure a real production prompt — system instructions and all — without sending it to anyone.

Watch what a prompt costs, in the editor

Estimating cost before you send is useful; seeing it as you work is better. Catalase is a free, open-source code editor that shows a live cost meter for every turn, lets you set a session cap — at which point it switches to a local model rather than continuing to spend — and runs models on your own machine through Ollama, where a turn costs nothing at all.

Download Catalase freeWhat is Catalase?

Related tools

All 30 free developer tools →