Skip to content
UniKit

LLM token counter

Count tokens and context usage precisely for GPT-4o / GPT-4.1 with the real o200k_base BPE vocabulary from gpt-tokenizer, plus a per-token breakdown; Claude and Gemini use closed vocabularies, so they are clearly labelled order-of-magnitude estimates.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Text

GPT-4o and GPT-4.1 are counted exactly with the o200k_base vocabulary from gpt-tokenizer; Claude and Gemini have closed vocabularies, so they are estimated from character counts and labelled as such.

Token counts

Cost uses a built-in reference price which changes over time — always check the official pricing page.

Enter text to count its tokens

Characters: 0 · Tokens: 0 · Context usage: 0% · Est. cost (USD): 0

What this tool does

  • Check whether a prompt fits inside the model context window before sending it
  • Estimate the cost of a call in tokens rather than characters
  • See how mixed Chinese, emoji and code text gets split (why five Chinese characters can cost three tokens)

Example

Input

hello world

Output

Model: GPT-4o (o200k_base,精确)
Characters: 11
Tokens: 2
Context usage: 2 / 128000 (0.0016%)
Estimated cost: $0.000005 (2.5 USD / 1M tokens)

GPT-4o uses a real BPE vocabulary: hello and world are one token each, two in total, and the context and cost figures are derived from that count.

Frequently asked questions

Which models are exact?

GPT-4o and GPT-4.1 use the o200k_base vocabulary from gpt-tokenizer — the vocabulary those generations (plus GPT-5 and the o-series) actually use — so the token count is exact. Claude and Gemini have closed vocabularies, so the tool estimates with characters ÷ average characters per token (3.5 / 4) and labels the result "closed vocabulary, estimated from characters"; the same text can differ by 10–30% between vocabularies.

How is the cost calculated?

Tokens are multiplied by a reference price per million input tokens built into the source: input only, no output tokens, no caching or batch discounts. Prices change when vendors update them, so treat the figure as an order of magnitude and check the official pricing page.

How are Chinese text and emoji split?

BPE cuts on fragments present in the vocabulary: common Chinese words such as 你好 and 世界 are usually one token each, while rarer characters or punctuation may split into several. Emoji typically take two or three tokens and composite (ZWJ) emoji take more. The token preview shows the text each token decodes back to.

Is the context usage cumulative?

No. It only shows how much of the model context window this one text occupies; system prompts, previous turns, tool schemas and the tokens the model will generate are not included. Add those separately when budgeting a real conversation.

Keywords:gpt-tokenizercontext windowllm-tokentokenizer

Related tools