LLM Token Counter (OpenAI, Claude, Gemini)
Count tokens in your prompt for GPT-4, GPT-3.5, Claude, and Gemini and predict API cost before you spend. Free, no signup — all counting runs locally, your prompt stays in your browser.
Last updated:
CommentsPaste your prompt above to estimate token counts for GPT-4, GPT-3.5, Claude, and Gemini, plus an approximate API cost. Estimation runs in your browser.
Tokens (est.)
45
Characters
168
Words
26
Bytes (UTF-8)
168
Estimated cost at GPT-4o pricing
If used as INPUT
$0.000113
2.5 USD / 1M tokens
If used as OUTPUT
$0.000450
10 USD / 1M tokens
Estimates use a fast statistical approximation and are within ±3% of official tokenizers for typical inputs. For billing-critical accuracy, use the provider’s official tokenizer (e.g. tiktoken for OpenAI).
What is Token Counter?
Large language models bill and limit context by tokens, not words — a token is roughly ¾ of a word in English, but code and non-English text tokenize differently. This counter estimates how many tokens your text uses across major model families and projects the API cost, so you can stay under context windows and predict spend before sending large prompts.
How to count LLM tokens
- 1Paste your prompt or document into the input area.
- 2See estimated token counts for GPT, Claude, and Gemini side by side.
- 3Enter expected output length to project total cost.
- 4Trim or split the input if it exceeds your model's context window.
Use Cases
Stay under the context window
Check that a prompt plus expected completion fits within a model's token limit before the API rejects it.
Estimate API cost
Project the dollar cost of a batch job by multiplying token counts by per-token pricing.
Optimize prompt length
Measure how much trimming boilerplate or examples reduces tokens (and cost) per call.
Code Examples
Rough English ratios
~4 characters ≈ 1 token
~0.75 words ≈ 1 token
1,000 tokens ≈ 750 wordsKey Concepts
- Token
- A sub-word unit produced by the model's tokenizer. Common words are one token; rare words, code, and punctuation split into several.
- Tokenizer differences
- GPT-4/3.5 use cl100k_base (BPE); Claude uses a similar BPE vocabulary; Gemini uses SentencePiece. The same text yields slightly different counts (~10–15%).
- Context window
- The maximum tokens (prompt + completion) a model can handle in one call. Exceeding it truncates or errors.
Tips & Best Practices
- ▸Code and non-English text tokenize less efficiently than English prose — expect more tokens per character.
- ▸For billing-critical counts, use the official tokenizer (tiktoken for OpenAI) — estimates are within a few percent, not exact.
- ▸Both input AND output tokens are billed; account for the completion length in cost projections.
- ▸Whitespace and repeated punctuation consume tokens too — trimming boilerplate reduces cost.
- ▸To see which part of a long prompt uses the most tokens, use the prompt token breakdown tool.
Frequently Asked Questions
How accurate is the token count?
This tool uses a fast statistical estimator that matches tiktoken output within ±3% for typical English/code inputs. For exact billing-critical counts, use the official tokenizer for your model.
Why do different models have different token counts?
Each model family uses a different tokenizer vocabulary. GPT-4/3.5 use cl100k_base, Claude uses a similar BPE tokenizer with a slightly different vocabulary, and Gemini uses SentencePiece. Ratios differ by ~10-15% for the same text.
How is the cost estimated?
Cost = (input tokens × input price) + (output tokens × output price), where prices come from each provider's public pricing page. Costs are illustrative and may change; check the official pricing before large jobs.
Try Next
Text Chunker
Split long text into overlapping chunks for embedding and RAG pipelines. Preview recursive, paragraph, sentence, or fixed strategies with live token counts. Runs 100% in your browser.
Related Tools
Prompt Token Breakdown
Break a prompt into segments and see how many tokens — and how much cost — each part uses. Find the heaviest section (system, few-shot examples, or user input) so you know exactly what to trim. 100% local.
Schema → Tool Definition
Turn a sample JSON payload into function-calling / tool definitions for OpenAI, Anthropic, and Gemini — side by side. Strict-mode toggle adds required + additionalProperties: false. 100% local, paste straight into your tools array.
Chat Messages Validator
Validate a Chat Completions messages array before you send it — checks roles (system/user/assistant/tool), required content, and common mistakes that cause a 400. 100% local.
Prompt Template Tester
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Prompt Diff
Compare two versions of a prompt line by line and see the token delta between them — so you know exactly what changed and whether an edit made the prompt cheaper or more expensive. 100% local.
Embedding Cost Calculator
Estimate the cost of embedding a corpus — pick a model, enter the number of documents and average tokens each, and get the total token count and dollar cost. 100% local.