LLM Token Counter (OpenAI, Claude, Gemini)
Estimate the number of tokens in your prompt for GPT-4, GPT-3.5, Claude, and Gemini. Predict API costs before you spend.
Last updated:
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).
Paste 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.
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.
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.
Related Tools
JSON Formatter
Format, beautify, and validate JSON online. Free, fast, and 100% local — your data never leaves your browser.
JSON Validator
Validate JSON online with instant error location and structure statistics (depth, keys, node types). 100% local — your JSON never leaves the browser.
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.
JSON → YAML
Convert JSON to YAML online. Preserve structure, comments-free, and ready to paste into Kubernetes or CI configs.
Timestamp Converter
Convert Unix timestamps to human-readable dates and vice versa. Supports seconds, milliseconds, ISO 8601, and timezone selection.