How it works
Language models never see your raw text. Before anything happens, your prompt is broken into tokens — short fragments the model was trained to recognise. Those tokens are what you pay for and what fills the model's context window, so knowing the count up front tells you both the cost and whether your prompt even fits.
This counter does the splitting live, in your browser, as you type or paste. Pick a model from the dropdown, drop your text in, and the readout updates instantly with the token count plus characters, words, tokens-per-word and characters-per-token. There is no upload step and no API call — the tokenizer code runs locally, so it works offline and is safe for confidential prompts.
The accuracy depends on which tokenizer the model uses, and the readout is honest about it with a badge:
- Exact — OpenAI models, counted with their real tiktoken encoding (
o200k_basefor GPT-5/4o/4.1/o-series,cl100k_basefor GPT-4 and GPT-3.5). This matches OpenAI's billing. - BPE proxy — Llama 3+, Mistral, DeepSeek, Qwen and Grok use byte-pair tokenizers in the tiktoken family, so they are counted with the closest OpenAI encoding. Expect a result within a few percent, not byte-identical.
- Estimate — Claude, Gemini and Cohere use SentencePiece tokenizers with no public JavaScript port, so these use a calibrated characters-per-token ratio.
The formula
input cost (USD) = tokens ÷ 1,000,000 × input price per 1M tokens
Worked example
Say you paste a 1,200-word product brief and want to send it to GPT-4o.
- The tiktoken
o200k_baseencoder counts it as roughly 1,560 tokens (badged Exact). - GPT-4o's indicative input price is $2.50 per 1M tokens.
- Input cost = 1,560 ÷ 1,000,000 × 2.50 = $0.0039 — about four-tenths of a cent.
- GPT-4o's context window is 128,000 tokens, so 1,560 tokens fills about 1.2% — plenty of room.
Now switch the dropdown to Claude Sonnet and the same text shows around 1,650 tokens (badged Estimate, from the characters-per-token ratio). The number is a little higher and clearly marked as approximate — useful for budgeting, but verify in Anthropic's console before a large batch.
The comparison table at the bottom runs your exact text through one representative model per family at once, so you can see the spread side by side:
| Model | Method | Why it differs |
|---|---|---|
| GPT-5 / GPT-4o | Exact | Real tiktoken o200k_base |
| GPT-3.5 Turbo | Exact | Real tiktoken cl100k_base |
| Llama 3.1, Mistral, Grok | BPE proxy | tiktoken-family stand-in |
| DeepSeek-V3 | BPE proxy | cl100k_base stand-in |
| Claude, Gemini | Estimate | SentencePiece ratio |
Tips
- Count the whole prompt, including system messages. Hidden system prompts, few-shot examples and retrieved context all consume tokens. Paste everything the model will actually receive.
- Budget for output too. This tool prices the input side; your bill also includes generated tokens, which are usually charged at a higher rate. Add an allowance for the reply.
- Watch code and non-English text. Both tokenize less efficiently than plain English — more tokens per character — so check them rather than assuming the four-characters-per-token rule of thumb.
- Treat cost as indicative. Prices move and vary by provider and region. Use the figure to compare models and size prompts, then confirm the live rate before high-volume runs.