Skip to main content
UFOZoo

Token Counter: Count Tokens for GPT, Claude & Gemini

Token counter online: count tokens for GPT, Claude, and Gemini with per-model token estimates, cost comparison, and context window tracking.

Updated 2026-08-16

Related Tools

Features

  • Count tokens with tiktoken precision (99%+ accuracy) for all major AI models
  • Real-time token counting as you type or paste text
  • Multi-language support: English, Chinese, Japanese, Korean, and mixed content
  • Copy and clear text functionality for easy workflow
  • Character and word count alongside token count
  • Cost estimation based on token count and model pricing: paste your text and see the API call cost instantly
  • Model-specific tokenizer switching: choose from GPT-5.6, Claude Sonnet 5, Gemini 3.6, DeepSeek V4, and more
  • Context window monitoring: shows how much of the model's context window your text occupies
  • Batch mode: paste multiple prompts separated by a delimiter and see each prompt's token count separately

How to Use

  1. 1Paste or type your text in the input area. Tokens will be counted automatically using tiktoken for maximum accuracy.
  2. 2View the token count, character count, and word count in real-time.
  3. 3Use the Copy button to copy your text, or Clear to start over.
  4. 4The token count shows 'tiktoken exact' when using precise counting, otherwise it shows an estimate.
  5. 5Select your AI model from the list to use the correct tokenizer: GPT-5.6, Claude Sonnet 5, Gemini 3.6 Flash, DeepSeek V4, and more.
  6. 6Check the cost estimation panel at the bottom right to see how much an API call with this text would cost based on your selected model's input and output pricing.
  7. 7Monitor the context window usage bar; it shows how much of the model's maximum context window your text uses, helping you avoid context limit errors.
  8. 8Use batch mode: separate multiple prompts with '---' on its own line to count tokens for each prompt individually and see a running total.
  9. 9Plan your API calls: enter system prompt, few-shot examples, and user message separately to count the total tokens needed for a full request.

Frequently Asked Questions

What is a token?

A token is the basic unit that AI models use to process text. Roughly: 1 token ≈ 4 characters in English, or ≈ 0.75 words. In Chinese, each character is typically 1-2 tokens. Token count determines API costs.

How accurate is the token counting?

We use OpenAI's official tiktoken library for 99%+ accuracy when the exact tokenizer is available. For models without specific tokenizers, we use the closest approximation or estimation algorithm.

Why is token counting important?

Token count directly determines API costs and whether your request will succeed. Exceeding the context window causes errors. Accurate counting helps you budget and optimize your AI usage.

How many tokens is my text? (English vs Chinese examples)

English: 'Hello, how are you today?' = 6 tokens. 'The quick brown fox jumps over the lazy dog' = 10 tokens. Chinese: '今天天气真好' = 5 tokens. Chinese text typically costs 2-3x more tokens than equivalent English text because each character encodes more information.

How does token count affect API costs?

Most AI providers charge per token, typically $0.01-0.15 per 1K input tokens and $0.03-0.60 per 1K output tokens depending on the model. A 2,000-token request on a mid-tier model costs a few cents total. The tool shows exact cost estimates based on the selected model's current pricing.

What is a context window and why does it matter?

A context window is the maximum number of tokens a model can process in one request (input + output). Current models range from 128K (GPT-5.3 Chat) up to 1M (Claude Sonnet 5, Gemini 3.6 Flash) and 2M (Grok 4.20). If your input exceeds the limit, the API returns an error. The tool's context bar shows your usage percentage.

Does token counting differ between models?

Yes. Each model family has its own tokenizer with slightly different rules. GPT-4o and later use o200k_base, Claude uses SentencePiece, Gemini uses a custom tokenizer. The tool automatically selects the correct tokenizer when you pick a model. Using the wrong tokenizer can give inaccurate counts affecting cost calculations.

How to estimate tokens for a full API request with system prompt and conversation history?

Count the tokens for the system prompt + each user message + each assistant response separately using batch mode, then sum them. Don't forget to add formatting overhead (~20 tokens per message boundary). The batch mode feature lets you paste all parts separated by '---' to see individual and total counts.

What happens when I exceed the context window?

The API returns a 'context_length_exceeded' error. To fix this: (1) reduce your conversation history, (2) shorten the system prompt, (3) truncate the user input, (4) use a model with a larger context window (e.g., Claude Sonnet 5 1M or Gemini 3.6 Flash 1M), or (5) implement sliding window summarization for long conversations.

What is the difference between token count and character count?

A character is one written symbol (a letter, digit, punctuation mark, or a single Chinese character), while a token is the unit a model's tokenizer splits text into: roughly 1 token ≈ 4 English characters or ≈ 0.75 words, and 1-2 tokens per Chinese character. For the same text the two counts rarely match: English spaces and punctuation often merge into a single token, while each Chinese character usually costs one token or more. This counter shows token, character, and word counts side by side so you can compare them directly.

Why does my token counter online show a different count than the OpenAI Playground or API?

Three usual causes: the model's tokenizer differs from the one selected here (GPT-4o and later use o200k_base, older models cl100k_base), the API adds formatting overhead like role markers and stop sequences that plain text counts do not include, and OpenAI occasionally ships updated vocabularies. This token counter uses the official tiktoken encodings, so with the correct model selected it matches the API within a handful of tokens. For billing, always count the full request (system prompt plus history), not just your new message.

Why is my API bill higher than the token counter estimated?

Because a real request is more than one message: the system prompt and the whole conversation history are re-sent and re-billed on every turn, output tokens usually cost more per token than input tokens, and cached or batch pricing differs from list prices. The token counter estimates a single text; for a full turn, count every message (the tool's batch mode does this) and multiply by your model's input and output rates separately.