LLM Token Calculator
GPT Tokens & Cost
Count GPT tokens with model-aware tiktoken encodings, estimate input/output API cost from pasted prompts, and compare tokenizer results in your browser.
Token counts and costs are estimates from the selected model’s tokenizer and the prices configured here. Counting runs only in your browser.
Results
Tokens
0
Characters
0
Est. input cost
—
Est. output cost
—
Model
GPT-4o
Pricing: $2.5/1M input, $10/1M output
- Characters0
- Tokens0
- ModelGPT-4o
What is this tool?
This LLM token calculator counts how a pasted string splits into tokens for supported GPT and reasoning models, then estimates input and output cost from the $/1M rates configured on this page. Tokens are the billing and context-window unit for most language-model APIs.
Tokenization is model-specific. The same text can produce different counts across GPT-4o, GPT-4.1, GPT-3.5, and reasoning families because vocabularies and merge tables differ. English, CJK, emoji, whitespace, and code all behave differently.
Use it for prompt sizing, chunk planning, and quick cost sketches. Treat every dollar figure as an estimate tied to the rates shown under the KPI — verify live provider pricing before making budget decisions.
Common use cases
- Size a system or user prompt before calling a chat API
- Compare how CJK or code samples tokenize across model families
- Rough-estimate input vs output cost for the same token count
How to use
- Paste the prompt, message, or document chunk. Counts update live (debounced) — no Calculate click.
- Select the model from the dropdown (SSR-labeled Select).
- Read the top KPI: token count, character count, and estimated input/output cost for that count.
- Use Sample for a short release-notes prompt, Copy for a text summary, or Clear to reset.
Examples
| Input / setting | Output | Notes |
|---|---|---|
gpt-4o + Hello world | 2 tokens; 11 characters | Short English sample. |
gpt-4o + antidisestablishmentarianism | 6 tokens; 28 characters | One long English word → multiple subwords. |
gpt-4o + function add(a, b) { return a + b; } | 13 tokens | Small code snippet. |
안녕하세요 on gpt-4o vs gpt-3.5-turbo | ~2 vs ~5 tokens | CJK tokenizer gap — same string, different models. |
Practical pitfalls
- Estimates only: Configured $/1M rates can lag official price changes. Always check the provider’s current pricing page before budgeting.
- Tokenizer ≠ full bill: Chat templates, tool/function schemas, and multimodal tokens may add tokens the paste box does not see.
- Unique vs many “chars÷4” estimators: this page uses model-aware tiktoken encodings and shows input vs output cost for the same count side by side.
- Huge pastes can stress browser memory while the WASM tokenizer runs — keep chunks practical.
References
Last reviewed: 2026-07-27
Frequently asked questions
- Are the token counts exact for the OpenAI API?
- Counts use the bundled tiktoken library with a model-aware encoding, which matches common OpenAI chat tokenizers closely. Chat templates, tools, and image tokens can still differ from what the API bills.
- Are cost estimates official prices?
- No. Costs multiply the counted tokens by the $/1M rates configured in this tool. Always verify current provider pricing before budgeting.
- Does it count output tokens separately?
- It counts the pasted text once, then shows estimated cost if that same token count were billed as input or as output. It does not simulate a model completion.
- Is my prompt uploaded?
- No. Tokenization and cost math run locally in your browser after the tokenizer loads.