Count tokens without a model API

CodeMoment · Updated 2026-10-31

A token count is a property of a tokenizer, not of the alphabet. The same sentence is a different length under two encodings, and an estimate is not the provider's own count. You can still measure the text in the browser, without sending it to a model.

o200k_base is the encoding used for GPT-4o, GPT-4.1, the o-series, and the GPT-5 family. cl100k_base is the encoding used for GPT-4, GPT-3.5, and the common embedding models. The Token Counter runs both from a tokenizer bundled with the page. They disagree most visibly around Chinese characters, so a number you remember from one model will not carry over to the other. Pick the encoding that matches the model you will actually call.

Claude and Gemini on that page are a local formula, not those providers' tokenizers. Latin text is charged at about four UTF-8 bytes per token. Each CJK, kana, or Hangul character counts as one token. The result can differ from the bill the provider would show. Treat it as a bound you can compute offline, and check the provider when the limit is close.

A context-window figure next to the count is a fixed published size. The page does not look up the live model list. Use it to compare the count with a length you already know. It will not notice if a vendor changes a window tomorrow.

Splitting is a second step. The Token Chunker cuts the text into windows of at most the size you set, using the same OpenAI encodings, so those chunk lengths match the counter. Claude and Gemini chunks use the same local estimate, and a character is never split in half. Overlap is how many tokens the next window repeats. It has to be smaller than the chunk size. If the two numbers are equal, the next window starts where this one started and the split does not advance. Overlap is shared on purpose. Join the chunks back together and those tokens are counted twice. That repeated span is context for the next call, not a second copy of the file.

Neither page calls a model API, and neither uploads the text. Count with the encoding you will send. Chunk only after that count is the one you meant.