Token Counter

Free token counter on PC Tools Online. Paste a prompt, see whether it fits the context window, and split it if it does not. The count runs in your browser. The text is not uploaded. OpenAI models use the real tokenizer. Claude, Gemini, DeepSeek, Grok, Gemma, Llama, Mistral, Phi, and Qwen get a labeled estimate, not a fake exact count.

Split text that does not fit

Use this when the text is too long for one request. The cutter prefers a blank line, then a line break, then a sentence, then a space. It cuts on a token only when the piece itself is longer than the budget. Overlap is copied onto the next chunk so a cut sentence still has its ending.

Which encoding to pick

OpenAI’s tiktoken model list maps names to encodings. This page runs those two encodings. It does not invent a third one for a model that is missing from the list.

EncodingWhat this page doesMapped models
o200k_baseExact countgpt-4o, gpt-4.1, gpt-5 (names that start with gpt-5), o1, o3, o4-mini
cl100k_baseExact countgpt-4, gpt-3.5-turbo, text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002
Character divisorEstimate, about ±10–15%Llama, Mistral, Phi, Qwen. Not their real vocab files.
Same 4-character guessEstimate only. Not their tokenizer.Claude, Gemini, DeepSeek, Grok, Gemma. A size check, not a bill.

Claude, Gemini, DeepSeek, Grok, and Gemma are in the estimate group on purpose. This page does not ship their vocabularies, so it will not print a fake exact count. If a newer OpenAI model is not in the tiktoken map, do not assume o200k_base still applies. Check the model card.

How the count is made

For the two exact rows, the page loads gpt-tokenizer 4.1.2, a JavaScript port of the o200k_base and cl100k_base merge tables. The first count downloads that file from this site (about 4 MB for o200k, about 1.6 MB for cl100k). After that, counting stays in the page. A string that looks like a special token, such as <|endoftext|>, is counted as ordinary text, not as a control token.

The estimate rows divide Unicode characters by a fixed factor: 4 for Llama, Mistral, Qwen, DeepSeek, Gemma, Claude, Gemini, and Grok; 3.6 for Phi; 4.2 for a generic English guess. Only the OpenAI rows use a real vocabulary. The divisor is useful when you only need to know whether a prompt is short or about to fill the window. It is the wrong tool for an API bill, and it is worse for Chinese and Japanese than for English.

Words are split on spaces. That number is not meaningful for Chinese or Japanese. The character count is Unicode code points, not bytes.

How to use the number

  1. Paste the prompt and any document text, or open a .txt, .md, .json, .csv, or .log file. The file is read locally.
  2. Pick o200k_base for GPT-4o, GPT-4.1, GPT-5, and the o-series names above. Pick cl100k_base for GPT-4 and GPT-3.5. For Claude, Gemini, DeepSeek, Grok, Gemma, Llama, Mistral, Phi, or Qwen, pick that name in the estimate group. Those rows are a size check.
  3. Set the context ruler to the window you actually run. The menu is a measuring stick. It is not a claim about one model’s current limit.
  4. Leave room for the answer. If the prompt is already most of the window, the reply will be cut or the start of the prompt will be dropped.
  5. If you want a dollar sketch, type today’s input and output prices from the provider’s pricing page. The page multiplies tokens by that price and divides by one million. It does not look the price up, and it does not include cached input, batch, images, or tool definitions.

A chat request also adds a small formatting overhead per message. This box does not add it. If you are within a few dozen tokens of the limit, trust the API usage field, not this page.

Worked examples

These strings are the sample buttons above. Counts were checked against gpt-tokenizer 4.1.2.

A whole source file pasted “for context” still blows the budget before the question does. Paste the function. If the prompt is the problem rather than the length, run it through the Prompt Optimizer before you count it again.

What this page will not do

Questions

Why is this different from the number in ChatGPT?

ChatGPT counts the text plus message formatting, and sometimes a hidden instruction. This page counts the text in the box. The encoding also has to match. GPT-4o is o200k_base. Older GPT-4 is cl100k_base. Mixing them up moves the number even when the words do not change.

Why doesn’t the Llama, Claude, or DeepSeek row match the app I use?

LM Studio, Ollama, Claude, Gemini, DeepSeek, and Grok each load their own tokenizer. Those rows on this page divide by about 4 characters. Being off by about 10 to 15 percent is expected, and Chinese can be further off. Near the limit, trust the app that will actually run the prompt.

Does a shorter count fix a bad answer?

Only when the window was full. A short prompt with the wrong format needs a rewrite, not a smaller number. Start with How to Write Better Prompts for Local AI Models.

Will the split land in the middle of a word?

It tries not to. It looks backward inside the budget for a blank line, a line break, a sentence end, or a space, and it will not give back more than about 40 percent of the chunk to find one. If one word is itself longer than the budget, that word is cut on a token boundary.

Can I trust the dollar figure?

Only as arithmetic on the price you typed. Confirm the current price on the provider’s site before you use it for anything that matters. Output tokens you have not written yet are a guess you typed into the third box.

Related guides and tools