Skip to content

Token counter ​

LLMs bill by tokens and measure context in tokens. Paste some text to see how many tokens it has and how a model splits it.

ToolToken counterOpenAI tiktoken, runs in your browser
Tokens
0
Characters
0
Characters per token
—

Claude, Gemini and Chinese models use their own tokenizers, so their counts differ. Text never leaves your browser.

How to use it ​

  1. Pick a tokenizer: o200k_base is used by GPT-5, GPT-4.1, GPT-4o, o1 and o3; cl100k_base by GPT-4 and GPT-3.5 Turbo (from the model table in OpenAI's tiktoken source).
  2. Paste text; the count updates as you type.
  3. Tick "Show how the text is split" to color every token. English, Chinese, code and whitespace split very differently.
  4. Click "Price this many input tokens" to open the AI API cost calculator with your count.

Counting happens in your browser; your text is never sent anywhere. The tokenizer (about 2 MB) loads once from jsDelivr.

FAQ ​

Are counts the same for Claude, Gemini or DeepSeek? ​

No. Each vendor uses its own tokenizer, so counts differ. This tool is exact for OpenAI models; for others, treat it as a ballpark and rely on the usage numbers their APIs return.

How do tokens relate to context length? ​

A model's context window is the maximum number of tokens it can handle at once. See which models fit your text in the context window lookup.

Discussion

Sign in with GitHub to comment. When asking for help, include your OS and the exact error message.

Updated:

gaodong.aiAboutPrivacyTermsContact

Created and maintained by Haorui Li, co-author of the KiT candlestick foundation model.

Independent tutorials, not affiliated with any product mentioned. Product names and trademarks belong to their owners. Check official pages for prices and policies.