AIWalay Tools

AI Token Counter

Count GPT-4o and GPT-4 tokens in your text with real tiktoken encodings, plus words, characters and an API cost estimator.

About the AI Token Counter

Count exactly how many tokens your text uses, with the same tiktoken encodings OpenAI's models use: o200k_base for GPT-4o and newer, and cl100k_base for GPT-4, GPT-3.5 and the embedding models. Counts update live as you type, alongside word and character totals.

Token counts drive everything in LLM work — context-window limits, truncation bugs and, above all, API cost. The built-in cost estimator multiplies your token count by per-million-token prices: pick a model preset or type your own current rates, since providers change pricing frequently. Claude and Gemini use different private tokenizers, so treat these counts as a close estimate (roughly ±15%) for them.

Everything runs in your browser. Your prompts — which often contain proprietary system instructions or customer data — are never sent to any server; the tokenizer itself is downloaded once and runs locally.

How to Use the AI Token Counter

  1. 1Paste your prompt or text into the box — the tokenizer loads automatically on first input.
  2. 2Read the live counts: o200k tokens (GPT-4o and newer), cl100k tokens (GPT-3.5/4), words and characters.
  3. 3For cost, pick a model preset or enter your own $ per 1M token prices.
  4. 4Check the estimated cost of sending this text as input.

Frequently Asked Questions

What is a token, and why is it not the same as a word?

Language models split text into tokens — chunks that can be whole words, word pieces or punctuation. In English, one token averages about four characters, so 1,000 tokens is roughly 750 words. Code, non-English languages and unusual formatting use more tokens per word, which is why an exact tokenizer beats rules of thumb.

Which encoding should I look at, o200k or cl100k?

Use o200k_base for GPT-4o and everything OpenAI has released since. Use cl100k_base for GPT-4, GPT-3.5-turbo and the text-embedding-3 models. The two often differ by several percent on the same text because o200k has a larger vocabulary — this tool shows both so you can match your actual model.

Does this counter work for Claude and Gemini?

As an estimate, yes. Anthropic and Google use their own tokenizers that are not publicly available, so no browser tool can give exact counts for them. In practice the tiktoken numbers land within about 15% of Claude and Gemini counts for typical English text — close enough for budgeting and context-window planning.

How is the API cost calculated?

Cost equals tokens divided by one million, multiplied by the model's price per million input tokens. This tool uses your o200k token count with the preset or custom price you enter. Remember the response costs extra at the (usually higher) output rate, and always verify current prices on your provider's pricing page.

Is my prompt sent anywhere when I count tokens?

No. The tiktoken encodings are downloaded once as JavaScript data and run entirely in your browser — your text never leaves your device. That makes the tool safe for proprietary system prompts, unreleased product copy and text containing customer data. You can verify by going offline after the page loads.

Related Tools