Understanding the LLM token and context size estimator — concept and principle
Large language models do not read characters or words; they read tokens: chunks such as a short word, part of a longer word or a punctuation mark. API prices, rate limits and the context window (how much text a model can consider at once) are all measured in tokens. This estimator gives a quick token count for pasted text and shows what share of a chosen context window it would use.
How it is calculated
- Estimated tokens = ⌈number of characters ÷ 4⌉, counting every character including spaces and punctuation.
- Words = number of whitespace-separated pieces after trimming the text.
- Share of context window = estimated tokens ÷ context window × 100%.
The context window is entered in tokens, for example 200,000.
The principle
Most modern models use subword tokenisers such as byte-pair encoding (BPE). BPE starts from single bytes or characters and repeatedly merges the most frequent adjacent pairs in a training corpus, so common English words become one token while rare words split into several pieces. For typical English prose this averages out to roughly 4 characters, or about three quarters of a word, per token. Text that was less common in the tokeniser's training data, such as Korean, other non-Latin scripts, source code, numbers and URLs, usually needs more tokens per character, so the ÷4 rule tends to undercount them.
Worked example
- Text: "Paste text here to estimate tokens." It has 35 characters including spaces and the full stop.
- 35 ÷ 4 = 8.75, rounded up to 9 tokens.
- Splitting on spaces gives 6 words.
- Share of a 200,000-token window: 9 ÷ 200,000 × 100 = 0.0045% (shown to 3 significant digits).
How to read the result
Use the estimate for budgeting, not billing. Remember that the context window must hold everything in one request: system prompt, conversation history, attached documents and the model's own reply. A prompt that fills 90% of the window leaves little room for output. If you are close to a limit or need exact costs, run the provider's own tokeniser or token-counting endpoint, because each model family splits text differently.
Common mistakes
- Applying the English ratio to Korean, Japanese, Chinese or code and underestimating by a large margin.
- Forgetting that output tokens also count toward the window and are often priced higher than input.
- Assuming two different models produce the same count for the same text.
Frequently asked questions
How many tokens is 1,000 English words?
Very roughly 1,300 to 1,400 tokens, using about 0.75 words per token.
Why do emojis and unusual symbols use several tokens?
Byte-level tokenisers may split a rare symbol into several byte pieces when no merged token exists for it.
Do spaces count?
Yes. Most tokenisers attach a leading space to the following word, so spaces are part of the tokens.
Sources: R. Sennrich, B. Haddow and A. Birch, Neural Machine Translation of Rare Words with Subword Units, ACL 2016 · OpenAI Help Center, What are tokens and how to count them?