Token Counter

Estimate token count for your text input. Based on OpenAI's encoding (cl100k_base). Useful for budgeting API costs.

0 chars 0 words
• ~1 token ≈ 0.75 English words (4 chars)
• System message + conversation history count as input tokens
• Each API request has a minimum token cost (usually 3-5 tokens)
• This counter uses approximate byte-to-token ratio (cl100k_base)

AI · tokens · LLM estimates

Estimate how many tokens a prompt or document might use with GPT-style models — in your browser, without an API key. Use it to stay under context limits and rough out cost before you call a provider.

Prompt length estimate No API key Client-side Context budgeting Cost awareness

What tokens are

Large language models split text into tokens — subword pieces, not always whole words. English often averages ~4 characters per token, but code, non-English text, and whitespace behave differently. Providers bill and enforce context limits in tokens (input + output), so counting matters for product UX and spend control.

Estimates ≠ billing truth. Each model family uses its own tokenizer (and versions change). For exact counts, use the provider’s tokenizer or API usage fields. This tool is for planning and ballparks.

How to use it

  1. Paste the system prompt, user message, or document chunk you plan to send.
  2. Read the estimated token count (and any character stats the UI shows).
  3. Leave headroom for the model’s reply and tool/function payloads.
  4. Split or summarize content when you approach the model’s context window.

Budgeting tips

SituationPractical approach
Long PDF / repo into a promptChunk, embed+retrieve, or summarize first
Chat with historyCount rolling history; truncate oldest turns
Code generationCode tokenizes densely — estimates run higher
Cost controlShorter system prompts; cache stable prefixes when the API supports it

Related cost thinking

Token count × price per million tokens ≈ dollar cost, separate for input and output. Pair this counter with the API Cost Estimator when you have published rates. Remember: retries, tool calls, and RAG context multiply real usage.

FAQ

Why don’t I match OpenAI’s counter exactly?

Different tokenizers and special tokens. Treat this as an approximation unless the tool documents a specific encoding match.

Is my prompt uploaded?

Counting runs locally in the browser. Privacy Policy.

Does this include output tokens?

It measures the text you paste (input side). Reserve additional budget for the completion you expect.

Related tools

Sponsored