LLM Token Counter

Estimate how many tokens a piece of text will use with LLMs such as GPT and Claude, and see how much of a 16K, 32K, 128K or 200K context window it fills. Everything is calculated locally in your browser.

FreeOnline Tool
Loading…

How to Use

  1. Paste or type the text you want to size up into the input box (mixed Chinese and English is fine).
  2. The page shows the total character count, CJK character count, other character count and the estimated token count in real time.
  3. The "context window usage" section below draws a progress bar for the common 16K / 32K / 128K / 200K window sizes so you can tell whether the text will overflow your target model's context limit.
  4. Press "Load sample text" to see the estimate applied to a mixed Chinese-English example.

Features

  • Pure local JavaScript - no external API or CDN is called and nothing you type is uploaded.
  • Uses the widely quoted approximation of roughly 1.7 characters per token for CJK characters and roughly 4 characters per token for everything else; the page states plainly that this is an approximation, not real tokenizer output.
  • Live counts of total characters, CJK characters, other characters and estimated tokens.
  • Four built-in context window sizes (16K/32K/128K/200K) with usage bars that turn red once the text exceeds the window.
  • A one-click sample text button for a quick trial.

Use Cases

Sizing a prompt before sending it
Check the token count of a long prompt before calling GPT-4o or Claude so it does not blow past the context window.
Keeping API costs under control
Estimate the input tokens of a request up front when working with per-token pricing, to help with budgeting.
Sizing RAG retrieval snippets
When building a retrieval-augmented generation pipeline, check whether retrieved passages will eat too much of the context.
Assessing mixed-language content
Get a quick token estimate for bilingual documents, support scripts and manuals, with separate ratios for Chinese and English.

FAQ

Is this token count exact?
No. It uses an approximation (about 1.7 characters per token for CJK characters and about 4 characters per token for everything else) rather than the official BPE tokenizer used by GPT or Claude. For exact numbers, use the model vendor's own tokenizer.
Which languages does it handle?
Any language. The tool separates CJK characters from everything else - letters, digits, punctuation, whitespace - and applies a different ratio to each, so mixed Chinese and English text still gets a reasonable estimate.
Is my text uploaded to a server?
No. All the counting happens locally in your browser; no external API is called and no text is sent anywhere.
How is context window usage calculated?
The estimated token count is divided by the selected window size (such as 128K or 200K) to give a percentage. Anything over 100% is capped at 100% and highlighted to show you have exceeded the window.