Token Counter

This free token counter shows exactly how many tokens your text uses, running OpenAI's real tiktoken tokenizer in your browser. It covers GPT-5, GPT-4o and the o-series, or the older GPT-4, GPT-3.5 and embeddings, and shows how much of a context window that fills and what the call costs at your rates.

…
Tokens
97
Characters
18
Words
—
Chars / token

Exact count from the real OpenAI tokenizer, running in your browser.

Does it fit?Context window

0.0% of a 128k window · 128,000 tokens left

What will it cost?

Enter your own rates, so the result is right for your model today and never goes stale. Check the provider's pricing page for current numbers.

Add at least one rate above and the cost appears here.

How do you count tokens for GPT-5 and GPT-4o?

Paste the text. The count comes from tiktoken, the tokenizer OpenAI publishes, running in your browser, so the number is exact and the text never leaves your device. Pick the encoding that matches your model:

Option on this pageEncodingModels (from tiktoken's own model list)
GPT-5, GPT-4o & o-serieso200k_baseGPT-5, GPT-4.5, GPT-4.1, GPT-4o, GPT-4o mini, o1, o3, o4-mini
GPT-4, GPT-3.5 & embeddingscl100k_basethe original GPT-4 and GPT-4 Turbo, GPT-3.5 Turbo, text-embedding-3 small and large, text-embedding-ada-002

Below the box, every token is shaded so you can see where the text was cut. Show token IDs swaps the pieces for their numbers, and Copy IDs copies the full list as JSON, which is what logit_bias and debugging ask for. New to tokens? The guide to tokens explains what they are.

Is the count exact?

For the text you paste, yes: it is the same count the model gets. A chat request adds a little on top, because each message is wrapped with its role. OpenAI's own guide to counting tokens puts that at about 3 tokens per message plus 3 that start the reply, so a system prompt and one user message add roughly 9 tokens to what you see here.

One limit, which we found while testing: a single unbroken run of more than 25,000 characters, such as a DNA sequence or a line of 30,000 equal signs, takes the tokenizer about a second at 30,000 and half a minute at 100,000, and the time keeps growing fast. Instead of freezing your tab, the page pauses the count and asks you to break the run up. Ordinary text, code and even long base64 strings are never close to that.

Why does the same text cost more tokens in another language, or as code?

Because the tokenizer packs plain English most densely. We measured one paragraph in English, the same paragraph in Portuguese, a JSON record and a JavaScript function:

SampleCharacters per token, GPT-4o and newerCharacters per token, GPT-4 and GPT-3.5
English paragraph5.04 (85 tokens)5.04 (85 tokens)
Same paragraph in Portuguese4.42 (95 tokens)3.93 (107 tokens)
JavaScript function3.643.71
JSON record2.852.85

Two things stand out. The newer tokenizer made the Portuguese paragraph 11% cheaper (95 tokens instead of 107) while English did not change, because its larger vocabulary covers more non-English words. And JSON costs about 77% more tokens per character than English prose: every quote, brace and colon tends to be its own token. The Chars / token box shows where your own text sits.

Will my prompt fit in the context window?

Pick the window size and the bar shows how much is used and how many tokens are left, turning amber near the limit and red past it. The window has to hold the reply too: a prompt that fills 95% of the window leaves almost no room for an answer. The sizes are round numbers on purpose; check your model's documentation for its exact limit.

How do I work out what a prompt will cost?

Type your provider's price per million tokens for input and output, how long you expect the reply to be and how many requests you plan. The page multiplies it out per request and in total. Output is usually priced several times higher than input, so a short prompt with long answers can cost more than a long prompt with short ones.

Prices are typed by you because they change often, and a built-in table would quietly go stale while still looking right. Your rates are saved in this browser. A comma works as the decimal mark, so 2,50 is read as 2.50.

What about Claude and Gemini?

The count here is exact for OpenAI models only. Claude and Gemini use their own tokenizers, which are not published like tiktoken, so a number here would be a guess for them. Both Anthropic and Google offer a token-counting endpoint in their APIs for the exact figure. The cost calculator still works for any model, because you supply the rates.

Read the guide: What Are Tokens in AI?Read more →

Frequently asked questions

What is a token?

A token is a chunk of text that a language model reads as a single unit. It is often a whole word, but common words, word pieces, spaces, and punctuation each count separately. As a rough guide, one token is about four characters of English, or roughly three quarters of a word.

How accurate is this token count?

Exact for the text you paste. It runs tiktoken, the byte pair encoding tokenizer OpenAI publishes, so the count matches what the model sees for that text. A chat request adds a few tokens on top for the message wrapping: about 3 per message plus 3 for the reply, according to OpenAI’s guide to counting tokens.

Why does my text in another language cost more tokens?

Because the tokenizer packs English most densely. Measured here, one English paragraph took 85 tokens and the same paragraph in Portuguese took 95 with the GPT-4o tokenizer, about 12% more. The older GPT-4 tokenizer needed 107 for the Portuguese, about 26% more, so newer models are cheaper for non-English text.

Why does code use so many tokens?

Quotes, braces, colons, indentation and camelCase boundaries often become separate tokens. Measured here, a JavaScript function averaged 3.6 characters per token and a JSON record 2.85, against 5.0 for English prose. So the same number of characters of JSON costs about three quarters more than prose.

How do I work out what a prompt will cost?

Enter your provider rates per million tokens for input and output, estimate how many tokens the reply will use, and set how many requests you plan to make. The tool multiplies it out and shows the cost per request and the total. Your rates are saved in your browser.

Why do I have to type the prices myself?

Because model pricing changes often, and a built-in table would quietly go stale and give you the wrong number about real money. Typing your rate once takes seconds, works for any model including brand new ones, and handles negotiated enterprise pricing that no public table would have.

Will my prompt fit in the context window?

Pick your model window size and the bar shows the percentage used and how many tokens remain, turning amber as you approach the limit and red past it. Remember the window has to hold the reply too, so leave room for the output as well as your prompt.

Which models does each option cover?

The first option uses o200k_base, which tiktoken maps to GPT-5, GPT-4.5, GPT-4.1, GPT-4o, GPT-4o mini, o1, o3 and o4-mini. The second uses cl100k_base, for the original GPT-4 and GPT-4 Turbo, GPT-3.5 Turbo and the text-embedding-3 and ada-002 embedding models. Pick the one that matches your model.

Does it count tokens for Claude or Gemini?

Not exactly, and the page does not pretend to. Claude and Gemini use their own tokenizers, which are not published the way OpenAI publishes tiktoken, so a number here would be a guess. Anthropic and Google both offer a token-counting endpoint in their APIs for the exact figure. The cost calculator works for any model.

Is my text sent anywhere?

No. The tokenizer runs entirely in your browser, so the text you paste never leaves your device and is not stored after you close the tab. You can safely check the token count of private prompts, code, or confidential content without it being uploaded to any server.

Rate Token Counter & help shape it

This tool is free and still growing. Tell us what works, what you would change, and what is missing. Your feedback is what decides what we build next.

Your rating
Tap a star to start

Built and tested by the ÆON Toolhub team. Last updated: October 19, 2026. How we test our tools