How to count AI tokens for GPT, Claude, and Gemini
Paste any prompt or document and see estimated token count before you call an API — no upload, no account.
LLM APIs bill by the token. If you are writing a long system prompt, stuffing context into a RAG pipeline, or trying to stay under a model's context window, you need a token count before you hit send. The AI Token Counter estimates tokens for GPT-4o, Claude, Gemini, and other popular models — entirely in your browser.
How it works
- Pick a model — each provider tokenizes text slightly differently. Select the model you plan to use so the estimate matches its typical ratio.
- Paste your text — prompts, documents, code, JSON payloads — anything you would send to an API.
- Read the stats — tokens, words, and characters update on every keystroke. Copy the token count with one click.
How tokens are estimated
Exact tokenization requires each provider's BPE vocabulary (tiktoken for OpenAI, a different tokenizer for Claude). This tool uses a calibrated heuristic: character count divided by a model-specific ratio, combined with a word-based estimate. For English prose the result is typically within 5–10% of the real count — close enough for budgeting and context-window checks.
For production billing, always verify with the provider's official tokenizer. For quick checks while writing prompts, this is faster than installing a library.
Why token count matters
- API cost — input and output tokens are priced separately. A 10,000-token prompt costs more than a 1,000-token one.
- Context limits — every model has a maximum context window. Exceed it and the request fails or gets truncated.
- Latency — more tokens means longer processing, especially on output.
Pair it with the cost calculator
Once you know your token count, plug it into the AI API Cost Calculator to see what a request will cost in dollars.