~/tokens · runs in your browser

Token Calculator

Count the tokens in any text with OpenAI's real tokenizers, see exactly how it is split, and estimate what it will cost to send and receive.

Tokens0
Characters0
Words0
Chars / token–
Tokens / word–

Estimate the cost

Enter the prices from your provider's pricing page, in price per 1 million tokens. Nothing is pre-filled because prices change.

Input cost–for the pasted text
Output cost–500 output tokens
Per request–input + output
Total–

Add at least one price above to see a cost.

Does it fit?

Your text as a share of common context window sizes. The window also has to hold the reply.

How the text is split

Each shaded block is one token (or a few tokens that make up one character). Hover a block to see its id.

Your text is processed in your browser and is never uploaded. OpenAI tokenizer counts are exact for the text you enter. Chat messages, tool definitions and images add a few extra tokens per request that this tool does not include, and other providers use different tokenizers, so treat totals as estimates.
01

How to use the token calculator

  1. Paste your text, prompt, code or document into the box. The count updates as you type.
  2. Pick a tokenizer. Use o200k_base for GPT-4o and newer models and cl100k_base for GPT-4 and GPT-3.5.
  3. Read the token count, the characters-per-token ratio and how much of each context window your text uses.
  4. Type your provider's input and output prices per 1 million tokens, the output length you expect and the number of requests to see the estimated cost.
02

What is a token?

Language models do not read letters or whole words. They read tokens: chunks of text drawn from a fixed vocabulary of tens or hundreds of thousands of entries. Common English words are usually one token, longer or rarer words are split into several, and punctuation, numbers, spaces and line breaks are tokens too. A rough rule for English is that one token is about four characters, or three quarters of a word, but the real number depends heavily on the language, the formatting and whether the text is code.

Tokens matter for two reasons. Every model has a context window, a maximum number of tokens it can handle in one request, and most APIs charge per token, with separate prices for the text you send and the text the model writes back. Knowing the count before you send a request helps you stay inside the limit and predict the bill.

To go deeper, read how tokenizers work, how many tokens a word or page uses, and how to reduce token usage.

03

Frequently asked questions

How does the token calculator count tokens?

It runs the same byte-pair-encoding vocabularies that OpenAI publishes (o200k_base for GPT-4o and newer models, cl100k_base for GPT-4 and GPT-3.5) directly in your browser. The count is exact for the text you paste with that tokenizer.

Is my text uploaded anywhere?

No. Tokenizing happens on your device. The page only downloads the tokenizer vocabulary once, and your text is never sent to a server.

Will the count match Claude, Gemini or Llama?

Not exactly. Each model family uses its own tokenizer, so the same text can produce a different count. Use the OpenAI counts as a close guide for English text and test with your provider's own counter before you rely on a number for billing.

How do I estimate the price?

Enter the input and output prices per 1 million tokens from your provider's pricing page. The calculator multiplies your token count by the input price, adds the cost of the output tokens you expect, and scales by the number of requests.

Why is there no price list built in?

Model prices change often and differ by provider, so a stale table would give wrong answers. Typing your current price takes a few seconds and keeps the estimate correct.

What is the difference between o200k_base and cl100k_base?

They are two vocabularies. cl100k_base has about 100,000 entries and is used by GPT-4 and GPT-3.5 era models. o200k_base has about 200,000 entries and splits many non-English scripts, emoji and code into fewer tokens.

More tools

Tokenizer pages and data

04

Token guides

Share this tool