Guides · Utiltown
What Is an AI Token and How to Count Tokens
Large language models do not read text by character. They read by token. A token is the smallest unit of text a model processes, and it can be a whole word, a fragment of a word, a punctuation mark, or even a single space. Because APIs bill by token and because exceeding a model\'s context window truncates earlier text, knowing how many tokens your input contains is essential for cost control and reliable output.
This article explains what tokens are, how they differ from characters, how OpenAI models count them exactly versus Claude and Gemini estimates, how context windows and API pricing work, and how to use Utiltown\'s Token Counter to count tokens locally in your browser — nothing is uploaded.
Core Concepts
Token is not the same as character. Consider these examples: `"apple"` equals 1 token, `"utiltown.com"` is about 2–3 tokens, and Chinese `"你好"` is about 2 tokens. A single common English word often counts as 1 token, while rare words, compound words, and punctuation may split into several tokens. Chinese characters typically take 1–2 tokens each. Because of this, a sentence with 100 Chinese characters may contain roughly 100–200 tokens, while 100 English words may contain only 130–160 tokens.
Models split text into tokens using a vocabulary. OpenAI uses public tiktoken vocabularies such as cl100k_base (GPT-3.5, GPT-4) and o200k_base (GPT-4o). Anthropic and Google do not publish their vocabularies, so exact counting for Claude and Gemini is not possible; estimates use a public vocabulary as a substitute.
The context window determines how much content a model can hold in memory at once. GPT-4o has a 128k context window; if your input plus expected output exceeds that, the model truncates the beginning of the text. Billing separates input and output tokens, and output tokens usually cost 3–10x more than input tokens, so long generations can dominate your bill.
How Different Models Count Tokens
- OpenAI (GPT-3.5 / 4 / 4o / o series): exact counting
based on tiktoken vocabularies. It runs locally in the browser, and
Token Counter shows an
Exactbadge. - Claude / Gemini: ≈ estimate because their vocabularies
are not public. Token Counter substitutes a public vocabulary and shows
≈ Estimate. Anthropic notes that newer models may run about 30% higher than the estimate, so treat results as reference only. - Chat wrapping: every message adds about 3–4 extra tokens
for role markers (
system,user,assistant), separators, and reply prompts. In long conversations these overheads accumulate, which is why Token Counter\'s chat mode adds roles per message to stay closer to real billing.
How to Use This Site\'s Tool
- Open Token Counter and select the model you want to count against.
- Paste a single text to count it directly. For chat conversations, use chat mode and add each message with its role so the count reflects real API usage more closely.
-
Check the badge: OpenAI models show
Exact; Claude / Gemini show≈ Estimate. - Check the cost card: input cost, output reference cost, and the price check date so you know which pricing schedule the estimate is based on.
- Check the context window bar: a percentage shows how much of the window your input consumes, with a red warning when you approach or exceed the limit.
Bottom Line
Understanding token counting helps you estimate API costs accurately and avoid context truncation. Paste your text in Token Counter now — local exact calculation for OpenAI, clearly marked estimates for Claude and Gemini, nothing uploaded, nothing retained.
Frequently Asked Questions
What is the difference between a token and a character?
A character is every symbol you see on screen — a letter, a digit, a punctuation mark, or a space. A token is the smallest unit a language model reads when processing text. A token can be a whole word, part of a word, a single punctuation mark, or even one space. For example, `"apple"` is 1 token, `"utiltown.com"` is about 2–3 tokens, and Chinese `"你好"` is about 2 tokens. Character count and token count are usually not equal; each Chinese character often takes 1–2 tokens, while common English words may take just 1.
Why do Claude / Gemini show ≈ Estimate instead of Exact?
OpenAI's tiktoken vocabularies (cl100k_base / o200k_base) are public, so exact counting is possible and marked with an Exact badge. Anthropic and Google do not publish their vocabularies, so this site substitutes a public vocabulary for estimation and marks results ≈ Estimate. Treat results as reference only; actual billing is based on the platform statement.
Why does chat history add dozens of extra tokens?
Each message adds about 3–4 extra tokens for role markers (system/user/assistant), message separators, and reply prompts. These overheads accumulate in long conversations, which is why Token Counter's chat mode adds roles per message to stay closer to real billing.
Does this tool upload my data?
No. Token Counter runs entirely in the browser. Your input text is never sent to any server and is never stored.
Is there a big pricing difference between OpenAI and Claude / Gemini?
Input and output have different unit prices; output is usually 3–10x input. Claude / Gemini estimates may differ from actual by about 30%. Rely on official pricing pages and your bill as the final authority — Token Counter is for estimation only.