Developer Tools
GPT Token Counter
Count GPT tokens and estimate OpenAI API cost for GPT-4o, GPT-4, GPT-4 Turbo, and GPT-3.5. Works in your browser, no signup, no upload.
GPT token counter
Counts are estimated using the public cl100k_base and o200k_base pre-tokenization rules with a calibrated subword model. Real tiktoken output typically lands within plus or minus 5% of these numbers. Your text is not uploaded.
Counts
Tokens are an estimate. Characters, words, bytes, and lines are exact.
Tokens (est.)
0
0.00 tokens/word avg
Characters
0
0.0 tokens per 100 chars
Words
0
Letter or number runs
UTF-8 bytes
0
What HTTP / JSON measure
Context window for GPT-4o
128,000 tokens total. The model fits the prompt and the response in this budget.
Remaining headroom: 127,500 tokens. Long conversations and tool calls also consume the window, so leave a margin for system prompts and chat history.
How accurate is this estimate
- Plain English prose: within plus or minus 3% of tiktoken in most cases.
- Code and JSON: within plus or minus 5%. Long identifiers can drift slightly because BPE merges are dictionary-dependent.
- CJK and emoji: within plus or minus 8%. cl100k_base tokenizes CJK roughly 1.5 tokens per character; o200k_base is closer to 1.
- When precision matters, confirm with the official tiktoken library in Python or its JavaScript port. This counter is built for budgeting and quick sanity checks.
How to use
- Paste a prompt, system message, code snippet, or any text into the editor. Counts update live as you type, and a Load sample button drops in prose, JSON, code, CJK text, and number-heavy strings so you can compare token rates.
- Pick a model from the sidebar. GPT-4o and GPT-4o mini use the o200k_base tokenizer; GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, and text-embedding-3-large use cl100k_base. The token total adjusts automatically.
- Edit the input and output dollar-per-million-token rates to match the price you actually pay (the defaults are public list-price snapshots), and set Expected output tokens to the size of the answer you expect. The total cost updates instantly.
- Check the context window bar to see how much of the model's budget your prompt plus expected output consumes. The bar turns amber above 70% and red above 90%, so you know when to trim or summarize.
- Use Copy summary to grab the model name, token count, byte size, context utilization, and cost estimate as plain text. Toggle Show token visualization to see each pre-token piece coloured by kind with its estimated subword token count.
About this tool
GPT Token Counter estimates how many tokens your prompt will consume on OpenAI's GPT-4o, GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, and text embedding models, then turns the result into an estimated dollar cost using rates you can edit. The estimator uses the public cl100k_base and o200k_base pre-tokenization regex from OpenAI's tiktoken library to split the input into the same pieces the real tokenizer sees: contractions, runs of letters, digit groups, punctuation, and whitespace. Each piece is then scored by a calibrated subword model that mimics how the BPE merges behave in production. The result lines up within a few percent of tiktoken on plain English prose, code, and JSON, and clearly flags itself as an estimate so you can budget a small safety margin. The page also reports characters, words, UTF-8 bytes, lines, the average tokens per word ratio, and how much of the model's context window your prompt plus expected output will consume. A token visualization panel shows each pre-token chip coloured by kind (word, number, punctuation, whitespace, non-ASCII) with its estimated token count, so you can see exactly which parts of a prompt are expensive. Cost is split between input and output, using editable per-million-token prices that come pre-filled with public list-price snapshots; replace them with your contract pricing in one click. The counter is useful when sizing system prompts, budgeting few-shot examples, pricing batch workloads, planning a RAG pipeline's context budget, or simply checking whether a long document will fit before paying for the call. Nothing leaves your browser. No API key, no upload, no rate limit.
Free to use. Works in your browser. No signup, no login.
Related tools
You may also like
Character Counter
Detailed character, letter, number, space, and line counts.
Open tool
TextWord Counter
Live word, character, sentence, paragraph, and reading time stats.
Open tool
TextTweet Character Counter
X (Twitter) tweet counter with t.co URL weighting, CJK x2, thread split preview.
Open tool
TextUTF-8 Byte Counter
UTF-8 bytes, UTF-16, code points, graphemes, plus SMS, cookie, and payload limits.
Open tool
TextText Cleaner
Remove duplicate lines, blank lines, extra spaces, tabs, and invisible characters.
Open tool