LLM Token Counter
Calculate LLM tokens, context capacity, and estimated prompt API costs across OpenAI, Anthropic, and Google models.
Runs in your browser. Nothing you add is uploaded.
What the LLM Token Counter does
Language models do not process text in words or characters; they operate on tokens generated by Byte Pair Encoding (BPE) tokenizers. Calculating tokens before making API calls prevents context window truncation and unexpected cloud API charges. This tool estimates tokens, character counts, and exact prompt/completion pricing across OpenAI, Anthropic, Google, and Meta models.
How to count LLM tokens and estimate API costs
- Select your target model (GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro, Llama 3) from the dropdown.
- Paste your prompt, code snippet, system prompt, or RAG context into the editor.
- Review estimated tokens, total words, character count, and tokens-per-word metrics.
- Inspect the Context Window Capacity progress bar to ensure you are well within model limits.
- Compare prompt (input) vs completion (output) costs across all top models in the comparison table.
The LLM Token Counter runs entirely in your browser — nothing you enter is uploaded, stored, or logged.
When to use it
Optimizing System Prompts and Agent Instructions
Trim verbose phrasing from agent system prompts that run on every API interaction to reduce monthly recurring inference costs.
Context Window Capacity Verification
Verify that large codebases, PDFs, or conversational histories fit within model boundaries (e.g. 128k for GPT-4o, 200k for Claude 3.5).
API Budgeting & Production Cost Projections
Accurately project operational expenses before deploying AI features across thousands of daily active users.
Good to know
- In general English text, 1 token is approximately 4 characters or ~0.75 words.
- Code, JSON payloads, and specialized punctuation typically consume significantly more tokens per word than standard prose.
- Everything runs locally in your browser: proprietary prompts and confidential documents are never sent anywhere.
Frequently asked questions
What is an LLM token?
Are my prompt texts uploaded anywhere?
Why do different models produce different token counts?
Why are completion tokens more expensive than prompt tokens?
Related tools
AI Code & Formula Explainer
Plain-English explanations of formulas, calculations and code.
Optional cloud mode
AI Text Rewriter
Rewrite text in a professional, friendly, concise or formal tone.
Optional cloud mode