Skip to content
GPT Tokenizer: What It Is, How It Works, and How to Count Your Tokens for Free
tokens

GPT Tokenizer: What It Is, How It Works, and How to Count Your Tokens for Free

A GPT tokenizer splits text into the tokens OpenAI's models read and bill, and OpenAI's free Tokenizer page shows you the split and the count.

7 min read

0

A GPT tokenizer is the tool that splits text into tokens, the small chunks of text OpenAI's models read and charge for. In English, one token is roughly 4 characters, or about three-quarters of a word, so 100 tokens comes to about 75 words, according to OpenAI's guide to understanding and counting tokens.

OpenAI's Tokenizer shows how any text splits, and developers count tokens in code with OpenAI's open-source tiktoken library. Counts change with the model, capital letters, spacing and language, so treat the rules of thumb as estimates. The OpenAI, Anthropic and Google pages cited here were checked on November 24, 2026.

What is the OpenAI tokenizer?

The OpenAI tokenizer is a web page at platform.openai.com/tokenizer where you paste text and see it split into tokens, with a running count of tokens and characters. Each colored block in the result is one token.

OpenAI's guide says a token can be a single character, part of a word, a whole word or a punctuation mark, and that spaces change how text is divided too. That is why a token count and a word count come out different for the same text.

The page has three tabs, one for each family of models: "GPT-5.x & O1/3", "GPT-4 & GPT-3.5 (legacy)" and "GPT-3 (legacy)". In the screenshot below, an 18-word sentence with a comma and a full stop comes out as 21 tokens on the GPT-5.x tab.

OpenAI Tokenizer on the GPT-5.x & O1/3 tab with the sentence "A GPT tokenizer splits your text into tokens, the small chunks that OpenAI models read and charge for." The counts, boxed in red, read Tokens 21 and Characters 102.
The sentence splits into 21 colored tokens and 102 characters on the GPT-5.x & O1/3 tab. Screenshot of OpenAI's Tokenizer (platform.openai.com/tokenizer), November 24, 2026.

How does the GPT tokenizer work?

A GPT tokenizer uses byte pair encoding, or BPE, which converts text into tokens and tries to keep common pieces of words together as one token. OpenAI's tiktoken library calls itself "a fast BPE tokeniser for use with OpenAI's models", and its documentation gives "encoding" as an example: it often becomes "encod" plus "ing", because "ing" is a common piece of English words.

The same documentation lists what BPE does well. The tokens convert back into exactly the original text, and the method handles any text, including text the tokenizer never saw in training. Text also gets shorter as tokens: on average, each token stands for about 4 bytes.

Each token is stored as a number, its token ID, and the model reads that list of numbers. Capital letters and spaces change which numbers you get. OpenAI's guide uses red, Red and " red" (with a space in front) as its example of text that an encoding can represent differently, and the Tokenizer shows it: typed on three lines, the three words get the IDs 1291, 7805 and 3592, and the 198 between them is the line break.

OpenAI Tokenizer on the GPT-5.x & O1/3 tab with red, Red and " red" on three lines. Tokens 5, Characters 12. The Token IDs view, boxed in red, shows [1291, 198, 7805, 198, 3592].
"red", "Red" and " red" get three different token IDs in the Token IDs view. Screenshot of OpenAI's Tokenizer, November 24, 2026.

Token IDs also depend on the encoding, the set of rules a model family uses to split text, and OpenAI's guide warns not to assume an example ID applies to every model. tiktoken names its encodings, such as o200k_base and cl100k_base. Each tab in the Tokenizer covers a different model family, and the same 18-word sentence counts 21 tokens on GPT-5.x, 22 on GPT-4 & GPT-3.5 and 23 on GPT-3.

OpenAI Tokenizer on the GPT-4 & GPT-3.5 (legacy) tab with the same sentence. The counts, boxed in red, read Tokens 22 and Characters 102.
The same sentence is 22 tokens on the GPT-4 & GPT-3.5 (legacy) tab, one more than on the GPT-5.x tab. Screenshot of OpenAI's Tokenizer, November 24, 2026.

How many words are 10,000 tokens?

10,000 tokens is about 7,500 words of English text, using OpenAI's rule of thumb that 100 tokens is about 75 words. OpenAI's guide calls these estimates, since sentence and paragraph length change the count, and says other languages have different ratios of characters, words and tokens.

TokensAbout this many English wordsAbout this many characters
10075400
1,0007504,000
10,0007,50040,000
100,00075,000400,000

The table works from OpenAI's two English rules of thumb, 4 characters per token and 75 words per 100 tokens, so it is an estimate for OpenAI's models only.

Google gives a wider range for its own models. Google's Gemini documentation says a Gemini token is about 4 characters and 100 tokens is about 60 to 80 English words, which puts 10,000 Gemini tokens at roughly 6,000 to 8,000 words.

How to count your tokens in three steps

To count tokens for an OpenAI model, paste your text into the Tokenizer and read the count under the box:

  1. Open OpenAI's Tokenizer at platform.openai.com/tokenizer.
  2. Pick the tab for your model. "GPT-5.x & O1/3" is the newest tab, and there is no GPT-6 tab as of November 24, 2026.
  3. Paste your text and read the Tokens and Characters counts. Click Token IDs to see the numbers behind each token.

The Tokenizer counts plain text only. OpenAI's guide says message structure, tools, schemas, images and files can all add to the full count of a request sent through the API.

For developers: tiktoken counts tokens in Python. Install it with pip install tiktoken, load an encoding and count the result:

import tiktoken
enc = tiktoken.get_encoding("o200k_base")
print(len(enc.encode("Your text here")))

To count a complete request, with images, files and tools included, OpenAI's guide points to its input-token counting endpoint (POST /v1/responses/input_tokens). The guide says counting is free, doesn't use your model's normal inference quota, and can't tell you how many tokens the answer will use. After a request, the response reports input, output and total tokens, and the Usage Dashboard shows your activity over time.

Which is the best tokenizer?

The best tokenizer is the one that matches the model you are using, because each model family splits text its own way. For OpenAI models that means the matching tab in OpenAI's Tokenizer or the matching encoding in tiktoken, and for Claude and Gemini it means each company's own counting tool.

tiktoken's list of models and encodings maps GPT-5, GPT-4.1, GPT-4o and the o1, o3 and o4-mini reasoning models to o200k_base, and GPT-4 and GPT-3.5 Turbo to cl100k_base. On November 24, 2026 the list had no entry for any GPT-6 model, and tiktoken returns an error for a model name it can't map, asking you to pick an encoding by name.

Claude counts differently again. Anthropic's token counting docs say Claude Opus 4.7 and later models, including Fable 5, 5.1 and 5.2, use a newer tokenizer that turns the same text into about 30 percent more tokens than earlier Claude models did. Anthropic's counting endpoint is free within per-minute request limits, and its count is an estimate that can differ from the real one by a small amount.

Gemini has its own count_tokens call, which Google's documentation says counts the input only, before you send it.

What token counts cost: three models on the same builds

On an API you pay per token, at a price that depends on the model and on whether the tokens go in, come out or are reused from a cache. Pat Simmons's comparison of what Fable 5.1, Opus 5.5 and GPT-6 Astra cost per build shows how much the token count moves that bill. Apps built on OpenAI's models pay OpenAI per token in the same way, as the explainer on what a GPT wrapper is covers.

He gave all three models the same three jobs: scenes from Moby Dick drawn entirely in code on one web page, a launch film with its own sound design, and a 3D skate game. The post lists the price per million tokens, the tokens each model used across all three builds, and the cost.

ModelPrice per million tokens (in / out)Input tokensOutput tokensCost, all three builds
Opus 5.5$4 / $20266.6 million1.1 million$106.93
Fable 5.1$10 / $5062.9 million524,000$90.99
GPT-6 Astra$10 / $5039.5 million238,000$60.20

The costs are API-equivalent: each model's real token counts priced at its published rates, while the builds themselves ran on subscriptions.

Opus 5.5 has the lowest price per token of the three and still cost the most, because it read 266.6 million input tokens, more than four times Fable 5.1's 62.9 million. GPT-6 Astra charges the same per token as Fable 5.1 and came in $30.79 cheaper, since it read 39.5 million input tokens to Fable's 62.9 million.

OpenAI's guide says the same thing about comparing models: a lower price per million tokens doesn't always mean a lower total, because models can tokenize the same text differently and produce different amounts of output and reasoning. Reasoning tokens, which a reasoning model uses internally before it writes its answer, don't appear in the answer but are billed as output tokens.

Pat's newer tests list tokens and cost too: his GPT-6.2 Astra review and testing tracks what each build cost and how many tokens it used, and so do the Fable 5.2 vs GPT-6.2 Astra vs Gemini 4 Carbon raw results.

Questions people ask

Is the OpenAI Tokenizer free?

Yes. The Tokenizer page loaded and counted text without an OpenAI login on November 24, 2026, and it shows no price.

What is tiktoken?

tiktoken is OpenAI's open-source Python library for turning text into tokens and counting them. It does in code what the Tokenizer page does in a browser, and you choose the encoding for your model, for example with tiktoken.encoding_for_model(model).

Is a token the same as a word?

No. A token can be one character, part of a word, a whole word or a punctuation mark, and in English one token averages about three-quarters of a word.

Do spaces and capital letters change the count?

Yes. OpenAI's guide says spelling, capital letters and the surrounding text change how a word splits, and "red", "Red" and " red" get three different token IDs in the Tokenizer.

What are input and output tokens?

Input tokens are what you send to the model, and output tokens are what it writes back. OpenAI's guide says input, cached input and output tokens can each have a different price, and cached input tokens are ones the model reuses through prompt caching.

How do I count tokens for something I paste into ChatGPT?

Paste it into OpenAI's Tokenizer first for an estimate. The Tokenizer's newest tab is GPT-5.x, so for newer models the number is a guide; the ChatGPT features and updates page on this site covers the models ChatGPT runs now.

Do Claude and Gemini use the same tokenizer as GPT?

No. Each company uses its own tokenizer and its own counting tool, so the same text gives a different count on Claude, Gemini and GPT models.

Where can I learn how a tokenizer is built?

Andrej Karpathy's video "Let's build the GPT Tokenizer" runs more than two hours and builds one in code. It is embedded below.

Sources

What did you think of this post?

Comments

Sign in to join the conversation.

You might also like.

Articles, builds, skills and tools on the same idea.
More At Work

AI FOR MORTALS.

Your daily AI edge that will make everyone wonder how you do it all.

Every weekday, the practical AI updates that matter, and exactly what to do with them.

The latest in AI, in plain English. Free, every weekday.