Token Counter

Count tokens with the real cl100k_base and o200k_base tokenizers in your browser — exact counts for the GPT-4, GPT-3.5, GPT-4o and o-series models, labelled with the models each count applies to. Free, no sign-up — runs locally in your browser.

Your work is auto-saved in this browser only, so a refresh won't lose it. Nothing is uploaded.

…or drop a file onto the box above. Files are read locally, never uploaded.

Tokens — cl100k_base
Exact for GPT-4, GPT-3.5-Turbo, text-embedding-3
0
Tokens — o200k_base
Exact for GPT-4o, GPT-4.1, o-series (o1 / o3 / o4)
0
Characters (Unicode code points) 0
Bytes (UTF-8) 0
Words 0
Lines 0

Other model families (Claude, Gemini, Llama, …) use different tokenizers — neither count above is authoritative for them, and this page will not pretend otherwise.

What is a token counter?

Language models do not read characters or words — they read tokens: sub-word chunks produced by a tokenizer trained on enormous amounts of text. Token counts decide what a prompt costs, whether a document fits in a model's context window, and where a long text must be split for retrieval or summarisation. A token counter tells you that number before you send anything: paste the text, read the count.

Most counters on the web estimate — characters divided by four, words times one-point-three. Those ratios are tolerable for English prose and quietly wrong for everything else: code, other languages, JSON, emoji. This counter instead runs the real tokenizers in your browser — the actual byte-pair encoding tables the models themselves use — so the numbers beside each encoding are exact for the models named, not approximations with a confident face.

How to use this tool

  1. Paste or type your text into the box above — or upload a text file or drop one onto the box; the file is read in your browser and never sent anywhere.
  2. Read the two token counts. Use the one for your model's encoding: cl100k_base for GPT-4 and GPT-3.5, o200k_base for GPT-4o, GPT-4.1 and the o-series. The counts update as you type.
  3. Use the character, byte, word and line counts for everything tokens do not decide: length limits, storage size, editorial budgets.
  4. For a cost estimate, multiply the token count for your model's encoding by that model's published input price — and remember a chat API adds a small per-message formatting overhead that no text-only counter can see.

Two encodings, honestly labelled

OpenAI's models have used two tokenizers in recent generations, and this page reports both rather than picking one silently. cl100k_base serves GPT-4, GPT-3.5-Turbo and the text-embedding-3 models. o200k_base serves GPT-4o, GPT-4.1 and the o-series reasoning models; its larger vocabulary usually counts the same text a little lower, and noticeably lower on text cl100k handles awkwardly — several non-English languages, code with long identifiers, symbol-heavy content. Neither encoding says anything authoritative about Claude, Gemini, Llama or any other family's models: they tokenize differently, their vendors' counts are the only exact ones, and a page that printed a single unlabelled "token count" for all models would be misleading you. What transfers is the order of magnitude; what does not is the number.

Why the rough rules of thumb break

"One token is about four characters" survives because it roughly holds for ordinary English. Watch it fail: a JSON payload spends tokens on every brace, quote and colon; a line of code spends them on indentation alone; a Chinese character typically costs a token or more by itself in cl100k; a single emoji can cost several. The sample button loads a paragraph of plain English — compare its tokens-per-word against the same counts for a pasted code file or a paragraph in another language, and the need for a real tokenizer makes itself. When a context window or an invoice is on the line, exact beats approximate.

Examples

The sentence "Hello, world!" is 4 tokens in both encodings — Hello, ,, world, ! — from 13 characters and 2 words. A typical English paragraph runs at roughly 1.3 tokens per word. A dense JSON object of the same character length can cost twice the tokens of the paragraph, because its punctuation is structural and every piece of it is billable. That spread — same characters, very different counts — is the whole reason this tool exists.

Frequently asked questions

Is my text uploaded anywhere?

No. Counting happens in your browser, on this page — the tokenizers run locally as part of the page. Nothing is sent to a server, and no API is called: you can disconnect from the network and the counts keep working. Your draft is auto-saved in this browser only, for 7 days, and the Clear saved draft button deletes it immediately.

Are these counts exact or estimates?

Exact — for the models named beside each number. The page runs the real byte-pair tokenizers: cl100k_base for the GPT-4 and GPT-3.5 families, o200k_base for GPT-4o, GPT-4.1 and the o-series. The count you see is the count those models' APIs would report for the same text (excluding any per-message overhead a chat API adds around your text, which belongs to the conversation format, not the text itself). For other model families — Claude, Gemini, Llama — neither number is authoritative, and the page says so instead of dressing a guess up as a count.

Why do the two token counts differ for the same text?

Because the two encodings were trained differently. o200k_base has a larger vocabulary, so it covers common words, code patterns and non-English text with fewer, bigger tokens — on most text it counts a little lower than cl100k_base. The gap widens on text cl100k handles awkwardly: some languages, emoji sequences and unusual punctuation can cost several cl100k tokens per character while o200k spends one or two.

What is a token, roughly?

The unit a language model reads and writes. Tokens are sub-word chunks learned from data: a common word is usually one token, a rare word splits into pieces, and punctuation, spaces and code symbols all cost tokens too. As a rough feel for English prose, 100 tokens ≈ 75 words — but that ratio collapses for code, for other languages and for symbol-heavy text, which is exactly why this counter runs the real tokenizers instead of a words-times-a-factor estimate.

Why is the character count different from the byte count?

Characters here are Unicode code points — what a person counts as letters. Bytes are the UTF-8 storage size: plain ASCII costs one byte per character, an accented letter two, most CJK characters three, an emoji four. Tokenizers work on bytes before merging them into tokens, so the byte count explains why text in some scripts costs more tokens per character than English does.

Does this tell me what my API call will cost?

It tells you the input-token half of it, exactly, for the models listed: multiply the count for your model's encoding by that model's input price per token. Output cost depends on the reply, which nobody can count in advance. Remember that chat APIs also wrap your text in message formatting that adds a few tokens per message — small next to any real prompt, and outside what any text-only counter can see.

Related tools