AI token counter

Count tokens of a prompt for GPT-4o, GPT-5, Claude, Llama and Gemini, see the cost from your own prices, split a long text into parts that fit a

loading AI token counter
About this tool

What is a token counter?

Language models do not read characters or words: they read tokens, pieces of text that are often a short word, part of a word or a symbol. The context window, the limit of a request and the price of an API call are all measured in tokens, so knowing how many a prompt has saves you from truncated answers and surprise bills.

This tool counts the tokens of any text in your browser. For the OpenAI encodings (o200k for GPT-4o, GPT-4.1, GPT-5 and the o-series, cl100k for GPT-4 and GPT-3.5) the count is exact. Anthropic, Meta and Google do not publish a tokenizer that runs offline, so for Claude, Llama and Gemini the number is clearly marked as an estimate: the count of a similar tokenizer times a factor you can edit. Type the price per million tokens from your provider and you get the cost; prices are not built in because they change, and yours are remembered only in this browser.

Two more modes cover what people do next. Split cuts a long text into parts that fit a limit, at line ends, with optional overlap and a "Part n/N" line. Pack files joins project files into one prompt with a directory tree, headers and an instruction at the end, ready for a chat window. Nothing is uploaded, and files are read only by your browser.

How to count tokens and plan a prompt

  1. Paste your prompt on the left. The table on the right shows the tokens for each model family at once.
  2. Type your provider's price per million input tokens in the price column to see the cost. Change the currency label if you need to.
  3. For Claude, Llama or Gemini, treat the number as a guide and leave a margin; adjust the factor if you have measured your own ratio.
  4. If the text is too long, switch to Split, set the maximum tokens per part and copy each part.
  5. To send a codebase, switch to Pack files, drop a folder, untick what you do not need and copy the result. Compare two versions of a prompt with the text diff, or tidy a JSON prompt first with the JSON formatter.

Examples

A short instruction

hello world is 2 tokens in both OpenAI encodings. tiktoken is great! is 6 tokens in cl100k.

Other languages and emoji

Accents, Japanese text and emoji take more tokens per character than plain English. A sentence in Portuguese with ção can cost noticeably more than its English version, which is why counting beats guessing from the word count.

Splitting a long document

A 30,000-token document with a limit of 8,000 tokens per part becomes four parts. With a 200-token overlap, each part starts with the last lines of the previous one so the model keeps the thread.

Common mistakes

  • Using characters divided by four as the truth. It is a rough rule for English; code, other languages and emoji differ a lot.
  • Counting only your text. The system prompt, previous messages and the answer also use the context window.
  • Trusting an estimate to the digit. For Claude, Llama and Gemini the number is approximate; keep a margin of 10 to 20 percent.
  • Using an old price. Providers change prices; type the current one from their page.
  • Packing secrets. Check files such as .env before sending a pack to a model; the tool leaves out binaries and vendor folders, not secrets.

Frequently asked questions

Is the count exact?

For GPT-4o, GPT-4.1, GPT-5, the o-series, GPT-4 and GPT-3.5 it uses the same tokenizers as OpenAI, so yes. For Claude, Llama and Gemini it is an estimate.

Is my text uploaded?

No. The tokenizers run in your browser and the text is never sent anywhere or stored. Only your preferences, such as prices and options, are remembered.

Why are there no prices built in?

Prices change often and an old table misleads. You type the price you pay, and the cost follows.

What does the overlap do?

It repeats the last lines of a part at the start of the next, so context is not lost at the cut.

Which files does Pack files leave out?

Images, archives, fonts, other binaries, files over 1 MB and folders such as node_modules and .git.

Report a problem