Count tokens in your text (OpenAI o200k_base)

Paste text to get the exact token count for OpenAI's o200k_base encoding, see where it is cut, and check it against context sizes.

How it works

  1. Paste your prompt or document
  2. Read the token count and how the text is split
  3. Check the percent of each context size

How many tokens is my text

Paste it into the box and the Tokens figure is the exact count for OpenAI's o200k_base encoding, the one used by GPT-4o, GPT-4.1 and the o1, o3 and o4 models, according to the tokenizer library's own model list. A token is a piece of text the model reads as one unit: a whole word, part of a word, a punctuation mark or a space plus a word. Worked example: The quick brown fox jumps over the lazy dog. is 44 characters, 9 words and 10 tokens, because the full stop is its own token and each word after the first carries its leading space. The word tokenization is 12 characters but only 2 tokens, token and ization. OpenAI describes about 4 characters per token as a rough guide for English; use the exact count above when it matters, because code, JSON, numbers and other languages split differently.

What the count does and does not cover

The count is exact for o200k_base only. Claude and Gemini use their own tokenizers, and those are not published as a library that a web page can run, so their counts for the same text will differ from this one. This page does not give a ratio to convert between them, because none is stated by those vendors. Anthropic offers a token counting API for Claude. The count is also for the text alone. Chat requests add a few tokens of formatting around each message, tools and images add more, and none of that is counted here. Text such as the literal characters <|endoftext|> is counted as ordinary text, the way it would be if it were quoted in a prompt, not as a control token.

Reading the token split

Text split into tokens shows each token with a bar between them. A space belongs to the token after it, so you will see | world rather than world with a lone space. New lines and tabs are shown as \n and \t. A single character can take several tokens. When a token holds only part of a character, such as part of an emoji, the neighbouring tokens are shown together as one piece, so the bars can be fewer than the token count. Switch to Token numbers to see the integer id of each token instead. Only the first 2,000 tokens are listed so the page stays fast; the count and the table always cover all the text.

Fits in context window

The table shows what share of five context sizes your text uses: 8,192, 32,768, 128,000, 200,000 and 1,000,000 tokens. They are plain numbers and are not tied to any model, so check the limit your model documents. The share is your token count divided by the size. The 10 tokens of the example above are 0.12% of 8,192. A context window also holds the reply and any system prompt or earlier messages, so leave room for them. Up to 500,000 characters are handled, and everything runs in this tab.

Frequently asked questions

Is this the same token count that ChatGPT uses?

It is the same encoding for models that use o200k_base, such as GPT-4o and GPT-4.1, so the text itself will count the same. A chat request also adds a few tokens of message formatting, which this page does not include.

Can I use this to count tokens for Claude or Gemini?

Not exactly. Claude and Gemini use their own tokenizers, which are not published as a library, so their counts differ from the o200k_base count. For Claude, Anthropic offers a token counting API that gives the real number.

How many characters is 1,000 tokens?

OpenAI gives about 4 characters per token as a rough guide for English, which makes 1,000 tokens about 4,000 characters. It is only a guide: code, numbers and non-English text split differently. The 100 characters of the letter a repeated come to 13 tokens, about 8 characters each. Paste your own text for the real figure.

Why does an emoji show as one piece but cost several tokens?

Tokens are cut from bytes, so one character can span several tokens. The melting face emoji is 3 tokens. When a token holds only part of a character, the neighbouring tokens are shown together as one piece so the text stays readable, and the count still counts every token.

Why does a number or a JSON body use so many tokens?

Digits, quotes, braces and keys each tend to take their own token. The 8 characters {"id":1} come to 5 tokens: {", id, ":, 1 and }. Paste your JSON and switch to Text pieces to see where the tokens go.

Is my text uploaded?

No. The text is processed in your browser and not uploaded. The tokenizer is a separate download that loads when the page opens, and your text is never sent anywhere.