AI Token Counter
Estimate prompt tokens and custom model cost locally in your browser.
Input
About This Tool
Estimate tokens, words, characters, and API cost for AI prompts before sending them to an LLM. Everything runs locally in your browser: nothing you paste is uploaded, stored, or logged, and there is no sign-up or usage limit. Read the full guide below for worked examples, best practices, and common mistakes to avoid.
Frequently Asked Questions
How accurate is this token counter?
It uses a practical estimate based on text length and word patterns. Exact token counts vary by model tokenizer, but this is useful for planning prompt size and rough API cost.
Does my prompt leave my browser?
No. The estimate runs in your browser and the text is not uploaded to a server.
Can I use my own model prices?
Yes. Enter the input and output price per one million tokens to estimate cost for any provider or model.
How an AI token counter estimates prompt size and API cost
An AI token counter estimates how many tokens your text will use, so you can check it against a model's context window and predict what an API call will cost. This tool divides your character count by four, which is the rule of thumb OpenAI gives for English text, then multiplies by the per-million-token prices you enter.
It is an estimate, not an exact count. Each model family has its own tokenizer, and the same sentence can produce different counts. Use this for planning and budgeting; use the provider's own counter when a few percent matters.
What a token is
Language models do not read letters or whole words. They read tokens: chunks of text that may be a word, part of a word, a space plus a word, a number, or a punctuation mark. Common words are often one token. Rare words, names, and code split into several.
OpenAI's help article on what tokens are and how to count them gives these English rules of thumb: one token is about four characters, or roughly three-quarters of a word, so 100 tokens is about 75 words.
Step by step: using the counter
- Paste your prompt, document, or transcript into the text box.
- Enter your model's input price per 1M tokens and output price per 1M tokens. The defaults of 1.00 and 3.00 are placeholders, not any provider's real prices. Copy yours from the provider's pricing page.
- Set expected output tokens, the length of the reply you expect.
- Read the tiles: estimated tokens, words, characters, and estimated cost for one call.
- Multiply by your expected number of calls for a monthly estimate.
The math, with worked examples
The formulas are simple:
- Input tokens = characters ÷ 4, rounded up
- Input cost = input tokens ÷ 1,000,000 × input price
- Output cost = output tokens ÷ 1,000,000 × output price
Example 1: a single prompt. A 2,000-character prompt is 500 estimated tokens. With the default prices and 500 expected output tokens:
- Input: 500 ÷ 1,000,000 × 1.00 = $0.0005
- Output: 500 ÷ 1,000,000 × 3.00 = $0.0015
- Total: $0.0020 per call
Example 2: a batch job. You summarise 1,000 documents of 40,000 characters each (about 10,000 tokens) and expect 500 output tokens each:
- Input: 10,000 × 1,000 = 10,000,000 tokens × $1.00 per million = $10.00
- Output: 500 × 1,000 = 500,000 tokens × $3.00 per million = $1.50
- Total: $11.50
Those prices are for illustration. Swap in the real ones before you plan a budget.
Notice that input dominates in batch jobs, and output dominates in chat. Output tokens are usually priced higher per token, but you control how many the model writes with instructions and max-token settings.
Quick conversions for English text
| Words | Approx. tokens | Typical content |
|---|---|---|
| 75 | 100 | A short paragraph |
| 750 | 1,000 | A one-page email or brief |
| 1,500 | 2,000 | A standard blog post |
| 7,500 | 10,000 | A long report |
| 75,000 | 100,000 | A short novel |
These come from the 0.75 words-per-token ratio. If you paste your text and the word count and token tiles disagree with this table, your text is probably unusual, which brings us to accuracy.
When the estimate is off
Other languages
The four-characters rule fits English. Many other languages need more tokens for the same meaning, and scripts such as Chinese, Japanese, Thai, and Hindi can use far more per character. Expect the estimate to run low for them.
Code and structured data
Symbols, indentation, and identifiers tokenise poorly. JSON with many short keys and brackets typically uses more tokens than its character count suggests. If you are working with data, the JSON formatter can minify it, which removes whitespace you would otherwise pay for.
Numbers and rare words
Long numbers, URLs, and unusual names split into many pieces.
Chat overhead
API calls add formatting tokens around each message, and tool definitions or images add more. Your visible prompt is not the whole bill.
Reasoning models
Models that think before answering can bill internal reasoning as output tokens. Your expected output figure should include a margin for that.
For exact counts: Use the provider's tokenizer. OpenAI publishes the tiktoken library and a web tokenizer, and Anthropic documents a token counting API that returns the exact count for a Claude request before you send it.
Context windows and why they matter
Every model has a maximum number of tokens it can handle at once, covering your prompt, the conversation so far, and the reply together. If your input already fills most of the window, the model has little room to answer. Use the token tile to check that a document fits, and leave space for the output you expect.
In a chat, the full history is re-sent each turn. A 20-turn conversation costs far more than 20 times the first message, because the earlier turns are billed again each time. Summarising old turns is a common fix.
Ways to cut token usage
- Trim instructions. Remove repeated rules and examples that do not change the answer.
- Send only what the task needs. Extract the relevant section instead of the whole document.
- Strip noise. Remove extra whitespace and duplicate text. The duplicate line remover helps with logs and lists.
- Cap the output. Ask for a format and length, such as "three bullet points under 20 words each".
- Use caching where offered. Some providers discount repeated prompt prefixes. Check current terms on the pricing page.
- Pick the right model. A smaller model for simple classification costs much less.
Budgeting an AI feature step by step
- Collect a sample. Gather ten real inputs, not invented ones. Real data is longer and messier.
- Measure each. Paste them into the counter and note the average and the largest token count.
- Add your fixed prompt. System instructions and examples get sent with every call, so include them in the text you measure.
- Estimate output. Run a few real replies through the counter to learn their typical length.
- Calculate per call, then per month. Use the average for the forecast, and the largest case for the worst-case check.
- Add a margin. A 20 to 30 percent buffer covers retries, longer inputs, and the tokenizer gap.
A support bot has a 1,200-character fixed prompt (300 tokens) and receives customer messages averaging 800 characters (200 tokens). Each call sends 500 tokens in and returns about 150 tokens. At 10,000 calls a month, that is 5,000,000 input tokens and 1,500,000 output tokens. With the default placeholder prices, that is $5.00 for input and $4.50 for output, so $9.50. With a 30 percent margin, plan for about $12.35.
Who this is for
Developers size prompts and set budgets before building. Product managers compare the cost of two prompt designs. Writers and researchers check whether a long transcript fits a chat window. Agencies quote automated content jobs. Your text stays in your browser, so pasting an internal document is fine.
More questions
Why is my provider's count different from this one?
This tool uses a fixed ratio, while real tokenizers split text by learned rules. A difference of 10 to 20 percent is normal, and it can be larger for code or other languages.
Does the token count include spaces?
The estimate does, since it counts all characters. Real tokenizers usually attach a leading space to the following word.
Do images and files count as tokens?
Yes, on models that accept them, but each provider has its own method. This tool counts text only.
What if the model prices change?
Just update the two price fields. The page does not hard-code any provider's rates.
Can I estimate cost per month?
Multiply the per-call cost by calls per day and by 30. Add a buffer for retries and longer-than-expected replies.