INTERACTIVE 5 min watch + tool

Token Optimizer

TOKENSCOST
0:00 / 0:00
0 comments

INTERACTIVE · 5 min watch + tool · 6 steps

The rundown

See what any prompt really costs across ChatGPT, Claude & Gemini, and how to write it leaner.

What you'll learn

  • What a token is: a piece of text, not a word and not a character
  • Why two tokenizers can count the same sentence differently
  • Which content is token-dense: code, JSON, long numbers, some scripts
  • The two sides of an API bill, and why conversation history costs too
  • Five steps that trim a prompt without losing the instructions that matter

Topics

TOKENSCOST

In one line

AI models don't read words. They read tokens, and you pay per token. This page's token optimizer shows how many tokens your prompt costs on each model and what's wasted; the lesson below teaches you why, and how to write leaner prompts for any AI.

Don't read yet. Play first. Paste a prompt you actually use into the tool below (or hit "Try an example") and press Analyze. Everything you're about to learn will make ten times more sense once you've seen your own words turned into a bill.

6Try the token optimizer

Token X-ray: paste a prompt, see what it really costs
Exact GPT counts

1What a token is

You just watched the tool do something strange: it counted your prompt and got a number that is not your word count and not your character count. That's because AI models never see your words. Before your prompt reaches the model, a tokenizer (the thing that chops your text into pieces) splits it into tokens, and the model reads (and bills) those pieces.

Think of it like LEGO bricks

The tokenizer snaps your sentence into LEGO bricks. A common word like "the" is one big brick. A rarer word like "understanding" gets broken into smaller bricks: maybe under + standing. Even "ChatGPT" might be three bricks: Chat + G + PT. And you pay per brick, not per word, not per letter.

A token is roughly a word-chunk. A few quirks worth knowing: a space usually attaches to the word after it (so " hello" is one token), and an emoji like 🚀 is often 1-3 tokens on its own.

For everyday English, two rules of thumb get you close:

  • 1 token ≈ 4 characters
  • 1 token ≈ 0.75 words, so 100 tokens is about 75 words, and one page (~500 words) is roughly 660-700 tokens.

These are estimates. The exact number depends on which tokenizer the model uses. As you saw in the tool's per-model cards, that is why the same prompt gets a different count on each model.

2How tokens are calculated

Before the model ever exists, its makers build a vocabulary of chunks by scanning a huge pile of text and asking, over and over: "Which two pieces appear next to each other most often? Glue them together."

Glue "t" and "h" enough times and you get "th"; glue "th" and "e" and you get "the". Repeat millions of times and you end up with a dictionary of, say, 100,000 or 200,000 chunks: frequent words become single chunks, and rare words stay broken into familiar fragments.

When you hit "Analyze", the tokenizer walks through your prompt left to right and greedily matches the longest dictionary chunks it can find. The result is a list of chunk IDs, and your token count is simply the length of that list.

For the 20% Under the hood: BPE, vocabularies, and exact counting

The merge-the-most-frequent-pair algorithm is BPE, or Byte-Pair Encoding (Gemini uses its cousin, SentencePiece). Because BPE falls back to raw bytes, anything is representable: any language, emoji, or binary.

Exact counting is only possible where the tokenizer is public:

  • GPT family: the open-source tiktoken library, with o200k_base (~200k vocab) for GPT-4o/4.1/o-series, cl100k_base (~100k vocab) for GPT-4/3.5. This page's tool uses the same encodings via gpt-tokenizer in your browser, which is why GPT cards say "exact".
  • Claude: proprietary BPE, vocab not public. Exact counts come only from Anthropic's count_tokens API endpoint.
  • Gemini: SentencePiece, not public. Exact counts come from Google's countTokens API.
  • Llama 3.x (BPE, 128k vocab) and Mistral's "Tekken" (tiktoken-based, ~130k) have open tokenizers.

For non-GPT models the tool applies calibrated character ratios (Claude ÷3.6, Gemini ÷4.0, Llama ÷3.8, Mistral ÷3.9) and labels them estimates, ±10%.

3Why the same prompt costs different amounts on different models

Look back at the tool's model cards. Same prompt, six different numbers. Each company trains its own tokenizer, on its own pile of text, with its own dictionary size.

And dictionary size matters: a bigger vocabulary generally means fewer tokens for the same text, because more whole words fit in a single chunk. That's why GPT-4o's ~200k-chunk tokenizer usually produces about 5-15% fewer tokens than the older ~100k tokenizers, and why Claude counts tend to run slightly higher than GPT counts for identical English text.

A token isn't a universal unit like a centimeter. It's each company's own measuring tape, which is why one prompt has six different price tags.

Exactly as the tool shows it: only the GPT counts are exact, because OpenAI's tokenizer is open source and runs right in your browser here. Claude, Gemini, Llama and Mistral counts are labeled estimates (±10%), because exact counts for those require each vendor's own counting API.

4What inflates your token count

Not all text is equally "token-dense". Because tokenizer dictionaries were built mostly from common English, anything unusual fragments into more, smaller bricks, and costs more:

Content typeEffect on tokensWhy
Source code+20-40% vs proseSymbols, casing and indentation fragment poorly
JSON with whitespaceHeavy inflationEvery quote, brace and indent costs tokens
Non-English text2-8× more per wordTokenizers are trained mostly on English; Indic and CJK scripts shatter into many small tokens, which matters if you work in Hindi, Tamil or other Indian languages
Numbers~1 token per 1-3 digitsDigits rarely merge into bigger chunks
Repeated boilerplateFull cost, every callThe model re-reads it on every single request

Quick experiment

Scroll up and paste the same short message into the tool twice: once in English, once in Hindi or Tamil. Watch the counts jump. Then try a snippet of pretty-printed JSON. Seeing it once teaches more than any table.

5Why output tokens and long chats cost more

So far we've only counted your prompt tokens (the input). But the bill has two sides:

Total cost = input tokens × input rate + output tokens × output rate

Two facts here surprise almost everyone:

First: the AI's answer costs more per token than your question. Output tokens typically bill at 2-5× the input rate. So the single biggest saving is usually telling the AI to keep its answer short and structured, rather than shortening your prompt. (We never quote specific per-token prices here; they change frequently, so always check the vendor's live pricing page.)

Second: in a chat, the whole conversation is the input. Every time you send a new message, all the previous turns get re-sent, and re-billed, along with it. That's why a long back-and-forth gets progressively more expensive per message, even when your new question is one line.

For the 20% Context windows and prompt caching

The re-sent history lives in the context window: the model's short-term memory, measured in tokens (the tool's meter compares your prompt against a large 200,000-token window). Where vendors support prompt caching, repeated prefixes (system prompts, long documents, prior turns) are discounted rather than billed at full rate, a major lever for agents and pipelines that re-send the same boilerplate thousands of times a day.

6How to write a leaner prompt for any model

The tool's auto-trim only does step one of this method. The same five moves work on every model, because they reduce bricks no matter whose tokenizer is counting:

  1. Delete filler

    Greetings, "please", "I was wondering if you could…", apologies, thank-yous, repeated instructions. The AI doesn't have feelings to spare, so this is pure cost, zero signal. (It's exactly what the tool strikes through in red.)

  2. Compress

    Merge sentences that say overlapping things. Turn paragraph-style requirements into terse labeled lines. If you included three examples, keep one minimal example.

  3. Structure

    Reorder into role → task → constraints → output format, with short labels instead of flowing prose. Structured prompts are both cheaper and more reliable.

  4. Preserve meaning, always

    Every requirement, fact, name and nuance survives. Optimization must never change what you're asking for. If cutting something could change the AI's behavior, keep it.

  5. Constrain the output

    Add an explicit length or format limit ("500 words", "a 5-row table"). Remember: output tokens are the expensive ones, so this step often saves more than all the others combined.

Watch the method work. Before, about 115 tokens:

"Hello! I was hoping you could possibly help me out with something. I need you to write a blog post for my website. The blog post should be about artificial intelligence agents. It should be informative and interesting. Please make sure the blog post is well-written and engaging for readers. The post should be around 500 words or so. Also, please make sure to include a catchy title for the blog post. Thank you so much for your help with this!"

After, about 28 tokens, roughly 75% saved:

"Write a 500-word engaging blog post on AI agents for a tech website. Include a catchy title."

Same instruction. A quarter of the cost. For one chat message, who cares. In an automated pipeline calling an AI thousands of times a day, that difference is real money.

Your turn

Scroll back up to the token optimizer, paste a prompt you use often, and apply the five steps by hand. Re-analyze your rewrite and watch the per-model numbers fall. That before/after feeling is the whole lesson.

Common questions

How many tokens is my prompt?
Paste it into the token optimizer at the top of this page. GPT counts are exact (the tokenizer is open source and runs in your browser); Claude, Gemini, Llama and Mistral counts are labeled estimates (about ±10%). Rule of thumb for English: 1 token ≈ 4 characters, or about 0.75 words.
Why does Claude count differently than ChatGPT?
Each company trains its own tokenizer with its own vocabulary size, and a bigger vocabulary generally means fewer tokens for the same text. GPT-4o's ~200k-entry tokenizer usually produces about 5-15% fewer tokens than older ~100k tokenizers, and Claude counts tend to run slightly higher than GPT counts for identical English text.
Do spaces and punctuation cost tokens?
Yes, everything becomes tokens. A space usually attaches to the word after it, so " hello" is one token. But heavy formatting adds up fast: in indented JSON, every quote, brace and indent costs tokens.
Why are my bills higher in Hindi, Tamil or other Indian languages?
Tokenizers are trained mostly on English, so Indic and CJK scripts fragment into many small tokens, roughly 2-8× more tokens per word. The same message in an Indian language can cost several times its English equivalent.
Why do output tokens cost more?
Vendors typically price output tokens at 2-5× the input rate, which is why constraining the answer's length and format often saves more than shortening your prompt. Check each vendor's live pricing page for current rates; they change frequently.
Why does a long chat get more expensive over time?
Every new message re-sends (and re-bills) the entire conversation so far as input. The longer the chat, the more tokens each new turn costs. Where supported, prompt caching discounts those repeated prefixes.

What you just learned

  • Tokens are the real unit. AI reads and bills word-chunks (LEGO bricks), not words or letters. English: ~4 chars or ~0.75 words per token.
  • Counting is just chunk-matching. A tokenizer greedily matches your text against its dictionary; the count is the length of that list.
  • Every model measures differently. Different tokenizers and vocab sizes → different counts for the same prompt. Only open tokenizers (GPT) give exact numbers; the rest are estimates.
  • Some text is expensive. Code +20-40%, heavy JSON, numbers, and non-English text (2-8× for Indian languages) all inflate counts.
  • Output is the big lever. Answers bill at 2-5× the input rate, and chats re-send their whole history every turn.
  • The five-step trim. Delete filler → compress → structure → preserve meaning → constrain output. The example went from ~115 to ~28 tokens (~75% saved).
Part of the aiagentsdaily Guide · Last updated June 2026

Step 1 / 6

Measure before you cut

Paste the prompt into the tool below and read the count. A token is about four characters of English, or roughly three quarters of a word, but that is a rough guide: two tokenizers can count the same sentence as 8 and 7 tokens, so measure with the tokenizer that matches the model you will call.

Step 2 / 6

Delete filler

Remove greetings, apologies and repeated politeness. None of it changes the answer, and every piece of it is counted as input.

Step 3 / 6

Compress

Combine sentences that say the same thing. One clear sentence costs less than three that overlap.

Step 4 / 6

Structure the task

State the task, the context, the constraints and the output format as separate, clearly marked parts. A structured prompt is shorter to write and easier for the model to follow.

Step 5 / 6

Preserve meaning

Keep every requirement or fact that could change the result. A shorter prompt is only useful if it still asks for the right thing: remove waste, never the instructions that matter.

Step 6 / 6

Constrain the output, then re-check

Ask for five bullets, fewer than 200 words or a small table instead of leaving the length open, because output tokens are usually priced higher than input. Then compare the revised prompt against your original checklist. In the video's example a 45-token prompt became 31 tokens with every topic kept, about 31 percent fewer input tokens, while the answer's length requirement stayed the same.

Moirangthem Margareth Devi

Moirangthem Margareth Devi

Founder, AI Agents Daily

Founder of AI Agents Daily. She tests AI tools and teaches non-technical people how to put them to work.

More guides like this

4 min watch
Cursor AI

Cursor AI tutorial for beginners: plan first, then build the app step by step

Watch now
New 6 min watch
Grok

Grok AI Image Generator Tutorial 2026 - Create Realistic AI Images with Better Prompts

Watch now
5 min watch
NotebookLM

NotebookLM tutorial for beginners: turn your own sources into answers you can verify

Watch now

Comments

No comments yet. Be the first.