Multiple LLMs · Explicit counting methods

LLM Token Counter

Paste a prompt and compare supported LLM tokenizers. Inspect the count, text boundaries and token IDs before choosing a model-aware counting method.

Accuracy note

Raw encodings count the supplied text exactly for that encoding. Compatible model views exclude some request formatting; provider API usage remains authoritative for complete requests.

How the LLM token counter works

Start with the same plain-text prompt and choose a raw encoding from the model selector. The counter splits the input into token pieces and displays the corresponding IDs. Keep punctuation, whitespace and line breaks unchanged when comparing two tokenizers, so a change in input does not get mistaken for a difference between models.

For a useful multilingual check, paste Hello world! 你好,世界!. The o200k_base raw encoding produces 8 tokens and cl100k_base produces 11. Switching between these two raw encodings keeps the text available for comparison. Selecting a chat-model workflow can introduce message formatting, so compare like-for-like inputs when interpreting the result.

LLM token counter vs word counter

Words are not universal model input units. A token may be a word, a word fragment, punctuation or another character sequence. The vocabulary determines the mapping, which is why the same text can produce different token boundaries and totals under different encodings. Numeric IDs are meaningful only alongside the tokenizer that produced them.

Use a word counter for an editorial length requirement and an LLM token counter to inspect a model input. A short code sample or compact JSON object can have a different token density from ordinary prose. The practical comparison is the actual text under the intended tokenizer, rather than a fixed rule such as one token per word.

LLM token count by model

This table uses the same support data as the model directory. Published base-text tokenizers can run locally, compatible views are labeled as such, and provider API methods remain separate. An API-only row documents a counting method; it does not mean that the provider's tokenizer has been loaded into this browser.

When migrating an application, record the text, selected tokenizer and count for each test case. Then check a complete request with the target provider. System instructions, conversation templates, tool definitions and media can change the input beyond the visible text. Use the linked model guides to understand where each local measurement stops.

ModelEncoding / tokenizerIs the count exact?
GPT-5.6o200k_base (compatible view)Compatible
DeepSeek V4 FlashPublished DeepSeek V4 tokenizerExact base text
Kimi K3Published Kimi K3 vocabularyExact base text
Grok 4.5Provider tokenizer via xAI TokenizeTextExact via API
Gemini 3.6 FlashProvider tokenizer via Gemini countTokensExact via API
Claude Sonnet 5Provider tokenizer via Anthropic count_tokensExact via API
DeepSeek R1Published DeepSeek R1 tokenizerExact base text
GPT-OSS 20B & 120Bo200k_base (Harmony wrapper excluded)Compatible base text

Frequently asked questions

Can one LLM token counter work with multiple models?

Yes, when it selects the appropriate supported tokenizer or clearly identifies a reference view. A single vocabulary does not reproduce every model's tokenization.

Why does the count change between o200k_base and cl100k_base?

They use different vocabularies and merge rules, so the same character sequence can be represented by a different number of token IDs.

Are token IDs portable between models?

No. Store the tokenizer or encoding name with the IDs. Decoding an ID list with another vocabulary can produce different text.

Can I compare Chinese, English and source code?

Yes. Paste the original text and switch supported raw encodings. Preserve spacing and punctuation if you want a controlled comparison.

Does the local count include the whole API request?

Only if all relevant text and formatting are represented and the correct tokenizer is used. Provider wrappers, tools and media may require a separate model-aware counting operation.

Where can I plan room for a response?

Use the linked LLM token calculator to add an output reserve and other input allowances to a measured prompt count.