Count and Estimate Tokens for LLM Prompts
Token counts affect context-window limits and API costs. This tool uses browser-based OpenAI tokenizer encodings for supported GPT model families and a clearly labeled estimation method for other providers. Your prompt text is processed locally in your browser.
Exact Tokenization for Supported OpenAI Models
Modern OpenAI models such as GPT-4o and GPT-4.1 use the o200k_base encoding, while GPT-4 legacy models and GPT-3.5 use cl100k_base. The tokenizer splits text into token IDs; the number of IDs is the text token count. This counts text only, not all chat-message, tool, image, audio or other request overhead.
Estimates for Claude, Gemini and Other Models
Tokenizers differ between model providers. When an official tokenizer is not running in this page, the tool estimates token usage from an OpenAI reference encoding and a model-family adjustment factor. These results are approximate and can vary by language, punctuation, code and model version. Do not treat estimates as billing-grade counts.
Understand Context-Window Usage
Select a context-window size to see how much of it the text estimate or count would use. A real request may also include system instructions, message formatting, conversation history, tool definitions, images and generated output, so the text-only result is not the complete request-token total.
Estimate API Costs by Model
Choosing a model pre-fills its published input and output prices, and you can still edit both to match your provider's current rates. The calculator applies the input price to the current text token count and the output price to your expected output-token budget. Pricing changes frequently, so re-check the figures before relying on an estimate.
Private, Browser-Based Processing
The text is tokenized in your browser and is not sent to our server for counting. The tokenizer library is downloaded from a public CDN when the page loads. If the library cannot load, the page falls back to a labeled estimate rather than presenting a false exact count.