Estimate token count for your text input. Based on OpenAI's encoding (cl100k_base). Useful for budgeting API costs.
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.
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.
| Situation | Practical approach |
|---|---|
| Long PDF / repo into a prompt | Chunk, embed+retrieve, or summarize first |
| Chat with history | Count rolling history; truncate oldest turns |
| Code generation | Code tokenizes densely — estimates run higher |
| Cost control | Shorter system prompts; cache stable prefixes when the API supports it |
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.
Different tokenizers and special tokens. Treat this as an approximation unless the tool documents a specific encoding match.
Counting runs locally in the browser. Privacy Policy.
It measures the text you paste (input side). Reserve additional budget for the completion you expect.