AI Token Counter

Count tokens with OpenAI's o200k_base and cl100k_base and DeepSeek's official tokenizer in your browser. See every token and cost for GPT, Claude and Gemini.

  • Runs in your browser
  • Your data never leaves your browser
  • Free · No Sign-Up
Paste plain text, a prompt or code. Counts update as you type; editing or clearing cancels the previous count. Message roles, tool definitions, images and PDFs are not included.
Open a UTF-8 text file up to 20 MB. Reading a new file replaces the text. Typing, Sample or Clear discards an unfinished file read.
Enter the output tokens you expect. The table uses them to estimate output and total cost per request. It does not generate a response. Standard prices exclude batch and cache discounts.
Choose a tokenizer to view its first 2,000 tokens; choosing one also loads it if needed. Show token ids adds the numeric ids to the boxes. The total count includes every token.

Type or paste text. Counts update as you type.

Tokenizer vocabularies load from this site as needed. Input text stays in your browser.

— tokens (o200k_base) o200k_base counts automatically. Count on the DeepSeek V4 or cl100k_base card loads its vocabulary (0.5 MB or 0.4 MB); Retry appears after a load failure. Each count follows that tokenizer’s published rules. 0 characters 0 UTF-8 bytes 0 words 0 lines

o200k_base

exact

— tokens

GPT-5.5, GPT-5.4, GPT-4.1, GPT-4o, o3, o4-mini

DeepSeek V4

exact

— tokens

deepseek-flash, deepseek-v4-pro

cl100k_base

exact

— tokens

GPT-4, GPT-3.5 Turbo, text-embedding-3

Claude, Gemini, GPT-6

no local tokenizer

No tokenizer is published for local use. Get the exact count from the provider’s free token counting endpoint. The table below uses the o200k_base count as a rough reference for these models.

Cost by model

Model Input tokens Context used Input Output Total

≈ = o200k_base count used as a reference. These models use their own tokenizers; the real count differs. Anthropic says Claude 4.7 and later produce about 30% more tokens than earlier Claude models for the same text.

Token view

Each box is one token. Boxes in ⟨⟩ hold bytes that are only part of a character; the next token completes it.

Read the full guide What Is a Token in AI? How Tokenizers Count Your Text
Examples, details and FAQ Worked examples, how it compares with other tools, and answers to common questions.

Which models get an exact count

CardModelsWhy it is exact
o200k_baseGPT-5.x, GPT-4.1, GPT-4o, o1, o3, o4-miniOpenAI’s tiktoken model table maps these names to o200k_base
cl100k_baseGPT-4, GPT-3.5 Turbo, text-embedding-3Same table; the embeddings guide names cl100k_base for text-embedding-3
DeepSeek V4deepseek-flash, deepseek-v4-proBuilt from the tokenizer.json in DeepSeek’s offline token counting package
≈ referenceClaude, Gemini, GPT-6No local tokenizer is published; the row uses the o200k_base count

For Claude, Anthropic’s token counting endpoint is free and says its result is itself an estimate. It also says Claude 4.7 and later produce about 30% more tokens than earlier Claude models for the same text. For Gemini, Google’s token guide only offers “about 4 characters” per token and points to countTokens. OpenAI’s tiktoken has no entry for GPT-6, so this page does not claim one.

Examples

The sample prompt (the Sample button) is a 486-character code review request:

o200k_base gives 104 tokens, cl100k_base 104 and DeepSeek V4 105. With 1,000 output tokens, one request costs $0.03052 on gpt-5.5 and $0.001232 on deepseek-flash at peak rates (half that off-peak). For English the three tokenizers land within a few tokens of each other.

The gap opens with other scripts. The same one-line instruction in four languages:

TextCharacterso200k_basecl100k_baseDeepSeek V4
English: “Summarize the meeting notes below in three lines and list the decisions and action items.”89181817
Chinese: 请用三句话总结下面这份周报,并列出风险项。21162315

The Chinese line costs 44% more tokens on GPT-4 (cl100k_base) than on GPT-4o (o200k_base), because the larger vocabulary holds many more Chinese words. Some characters are not in cl100k_base at all: 🦜 becomes byte tokens, which the token view shows in hex inside ⟨⟩ boxes.

Cost and context columns

Costs use the standard per-million-token prices checked on 2026-10-01, without batch or cache discounts. Where a provider charges more for long prompts, the table switches rate: gpt-5.5 and GPT-6 above 272,000 input tokens, gemini-3.1-pro-preview above 200,000. DeepSeek rows also show the off-peak price, which DeepSeek sets at half the peak price. The context column divides the count by each model’s input limit and marks rows over it.

How this differs from other counters

Tested on 2026-10-01 with the Chinese sentence “你是一名资深后端工程师,正在评审一个合并请求:在 PostgreSQL 分析库前面加一层 Redis 读穿缓存。” (o200k_base 35 tokens, DeepSeek V4 26):

  • benchlm.ai token counter shows “~14 tokens” and lists 14 for every Claude, Gemini and DeepSeek model, about the character count divided by 4. The real counts are 35 and 26.
  • tokencost.app marks DeepSeek V4.1 Flash as “42~” and lists GPT-6 Luna and Llama 3.3 with plain numbers, although OpenAI has published no GPT-6 tokenizer and Llama 3 uses its own vocabulary. Its DeepSeek price is the off-peak rate.
  • token-counter.dev gives the correct 35 for o200k_base through tiktoken’s WebAssembly build, and has no DeepSeek tokenizer.

This page also fixes two problems of the common JavaScript port, js-tiktoken, which it used before. js-tiktoken reads \s with JavaScript’s rules, so text containing a byte-order mark (U+FEFF) or U+0085 can split differently from tiktoken. And its merge step slows down sharply on long runs without spaces: 20,000 Chinese characters in a row took over three minutes. Here the regex uses Unicode White_Space and the merge uses a priority queue, so the same input takes milliseconds.

Limits

  • Counts are for plain text. Message wrappers, system prompts, tool schemas, images and PDFs add tokens that only the provider’s counting endpoint sees.
  • Special tokens such as <|endoftext|> count as ordinary text for OpenAI (7 tokens), the same as tiktoken’s encode_ordinary; the page never throws on them, which the old version did. DeepSeek’s tokenizer.json recognises its own markers such as <|User|> as one token, and so does this page.
  • Claude, Gemini and GPT-6 rows are references, not counts. Use the provider’s endpoint before you rely on them.
  • Prices are a snapshot from 2026-10-01 and include no taxes, regional uplifts or negotiated discounts.
  • DeepSeek’s package says to run it with transformers. In our test, transformers 5.18.0 returned an empty list for Chinese text from this package; transformers 4.57.6 and the tokenizers library give the ids this page uses.

Related: check plain word and character counts with the Word & Character Counter, remove API keys from a prompt with Redact API Keys & Secrets, and convert batch request files with the JSONL Converter.

FAQ

Which counts are exact?

o200k_base, cl100k_base and DeepSeek V4. The tool runs the same vocabularies and merge rules as OpenAI's tiktoken and DeepSeek's official tokenizer.json, and its test suite compares the token ids with those reference implementations on more than 1,500 strings. Claude, Gemini and GPT-6 have no tokenizer published for local use, so those rows show the o200k_base count marked with ≈ as a reference only.

Why doesn't my API bill match the number here?

The tool counts one piece of plain text. An API request also contains message roles and separators, the system prompt, tool definitions, images and files. OpenAI says its input token count endpoint includes these formatting tokens, which local tokenizers do not see. Paste only the text you want to measure, or call the provider's counting endpoint with the full request.

Is my text sent anywhere?

No. Counting runs in a Web Worker in your browser. Tokenizer vocabularies are static files on this site, loaded on demand. After a task is terminated, the next count may load those files again. Requests contain no input text. You can confirm this in the Network tab of the browser's developer tools.

How large a text can I count?

Files up to 20 MB open with the Open file button, and pasted text has no fixed limit. Character statistics, pre-tokenization and token counting run in a Web Worker. Editing or clearing the input terminates the previous calculation. Only counts, statistics and the first 2,000 token labels return to the page. Large text can still take time to display in the input field. In our test (Apple M1 Max, Chromium 152, 2026-10-03), one million characters of mixed Chinese and English took 1 to 2 seconds to show in the input field and about 1.1 to 1.9 seconds more to count with o200k_base.

How current are the prices?

They were checked on 2026-10-01 against the official pricing pages of OpenAI, Anthropic, Google and DeepSeek, and the date is printed under the table. Providers change prices and add tiers without notice, so check the linked page before you commit a budget.