Token Counter & Context-Window Fit (with boundary view)
Paste text for an exact GPT-4o/GPT-4 token count, rough Claude, Llama 3, and Gemma estimates, and a colored boundary view. Nothing you type leaves your browser.
Type or paste text above to see its token count, boundary breakdown, and context-window fit.
Your text never leaves the page. The tokenizer runs locally in your browser after it loads; nothing you type or paste is uploaded or logged anywhere.
Overview
A token counter encodes your text with the real tokenizer OpenAI's GPT-4o and GPT-4.1 use (o200k_base) and the one GPT-4 and GPT-3.5 use (cl100k_base), giving an exact count, then adds rough character-based estimates for Claude, Llama 3, and Gemma. It also shows what percentage of five common context-window sizes, from 8K to 1M tokens, that count fills. Everything runs locally in your browser; your text is never uploaded anywhere.
How it works
- 1Paste or type the text you want to measure into the box.
- 2On first use, wait a moment while the tokenizer files load in your browser; nothing is sent anywhere during that load.
- 3Read the exact token count for GPT-4o/GPT-4.1 (o200k_base) and GPT-4/GPT-3.5 (cl100k_base), plus the labeled estimates for Claude, Llama 3, and Gemma.
- 4Switch the tab above the boundary view to see either OpenAI encoding split your text into individual, alternately highlighted tokens.
- 5Check the context-window fit bars to see what percentage of the 8K, 32K, 128K, 200K, and 1M tiers your text fills.
- 6Trim your text and watch the counts and bars update live until it fits the model you actually plan to use.
Worked example
A short customer-escalation prompt
Input (127 words, 779 characters): "Hi team, I need help drafting a response to a customer escalation. The customer is on our annual enterprise plan and reported that exports to CSV have been failing intermittently since last Tuesday's release. Their account has roughly 40,000 records across 12 projects, and the failure seems to happen only on exports larger than 5,000 rows. I've attached the last three support tickets, the relevant error logs from our export service, and a summary of the deploy that shipped Tuesday. Can you write a reply that acknowledges the impact, explains what we currently know about the cause, and gives a realistic timeline for a fix without overpromising? Please keep the tone calm and specific, and avoid restating information the customer already gave us in their original message." The tool counts 152 tokens under GPT-4o/GPT-4.1 (o200k_base) and 153 under GPT-4/GPT-3.5 (cl100k_base), against rough estimates of 223 (Claude), 205 (Llama 3), and 195 (Gemma). Against the context-window tiers, that is 1.9% of an 8K window and well under 1% of every larger tier, so this prompt fits comfortably anywhere.
The same sentence in two OpenAI encodings
Input: the Chinese sentence "系统提示:请总结以下季度报告中的三大风险,并引用具体页码。报告涵盖 2026 年 14 个地区的数据,同比增长 8.3%。" (61 characters). Under o200k_base (GPT-4o/GPT-4.1) it counts as 36 tokens; under cl100k_base (GPT-4/GPT-3.5) the identical text counts as 58 tokens, 61% more tokens for the same content. That gap is why a token counter built around only one encoding, or only around English prose, can quietly mislead for non-English text or for a model that uses a different tokenizer altogether.
Methodology & privacy
Token counting here uses real byte-pair-encoding (BPE) tokenizers, not a word or character estimate, for two of the five models shown. The exact counts come from js-tiktoken, a JavaScript port of OpenAI's own tiktoken library, running two of its published encodings entirely in your browser: o200k_base, the encoding behind GPT-4o, GPT-4.1, and OpenAI's o-series models, and cl100k_base, the encoding behind GPT-4, GPT-3.5, and OpenAI's embedding models. BPE splits text into subword units built by repeatedly merging the most frequent adjacent byte pairs seen in a large training corpus, so common words are usually a single token, longer or rarer words split into a few, and whitespace and punctuation get their own tokens. That is also why a token count differs from a word or character count, and why the exact same text can tokenize to a different length under a different encoding: the same 61-character Chinese sentence comes out to 36 tokens under o200k_base but 58 under cl100k_base, a 61% difference for identical content, because the two encodings were trained with different vocabularies. The boundary visualization is built by decoding each token id back to text on its own, so the highlighted spans, concatenated in order, reconstruct the exact original text; rendering stops after 2,000 tokens purely to keep the page responsive, and the count itself stays exact and unaffected by that cap. Claude, Llama 3, and Gemma do not ship a tokenizer that is practical to lazy-load in a browser tab: Claude's tokenizer isn't published at all, and Llama 3 and Gemma's real vocabularies are large binary files not worth the download for a rough number. Those three rows use a characters-per-token ratio instead, 3.5 characters per token for Claude, 3.8 for Llama 3, and 4.0 for Gemma, rough averages for general English prose. Every row using this shortcut is flagged as an estimate and rendered separately from the exact rows, never blended in as if it were a real count, and it can be off by a meaningful margin on code, non-English text, or unusual formatting, exactly where a character ratio and a real tokenizer diverge most. The context-window fit bars divide your token count by five common context sizes, 8,000, 32,000, 128,000, 200,000, and 1,000,000 tokens, and multiply by 100, capping the displayed percentage at 999% so an extreme count never breaks the layout. These five sizes are round figures representative of widely used tiers rather than one exact model each: 128K matches GPT-4o and GPT-4.1's published context window, and 200K and 1M match Claude's smaller and its current largest-context models; 8K and 32K stand in for smaller legacy and local-model tiers. Providers change context windows over time, so treat the fit bars as a check against common size tiers, not a live lookup of any single model's current limit.
- Source: Quora: How long of a prompt can I give ChatGPT?
- Source: Quora: How does ChatGPT remember the beginning of the conversation if it does not have a state and input size is limited?
- Source: Reddit r/LocalLLaMA: context parsing utility (counts tokens with tiktoken)
- Source: js-tiktoken (JavaScript port of OpenAI's tiktoken, used for the exact counts)
- Source: openai/tiktoken: model-to-encoding mapping (o200k_base / cl100k_base)
- Source: OpenAI API docs: GPT-4o model page (128,000 token context window)
- Source: Anthropic docs: Claude models overview (context window by model)
Every keystroke stays on your device. The tokenizer files load once from your browser's own network request after your first keystroke, but the text you type, the resulting counts, and the boundary view are all computed in local JavaScript and never sent to a server, logged, or stored anywhere.
FAQ
How long of a prompt can I give ChatGPT?
+
Length limits are measured in tokens, not characters or words, so paste your prompt here to see its exact GPT-4o/GPT-4.1 or GPT-4/GPT-3.5 count. Current chat models allow well into the tens of thousands of tokens, up to 128K for GPT-4o/GPT-4.1 and up to 1M for Claude's largest-context tier, but the provider's own published limit for the model you're using is always the authoritative number.
How does ChatGPT remember the beginning of the conversation if it does not have a state and input size is limited?
+
It doesn't remember anything outside its context window. The whole conversation so far, system prompt, your messages, and its replies, gets re-sent as tokens on every turn, and once that running total exceeds the model's context window, the oldest tokens get truncated or summarized away depending on the client. Paste your running conversation here to see how many tokens it currently costs.
How is a model's token limit calculated?
+
By counting tokens, not words or characters. Text is split into byte-pair-encoded subword units, common words are usually one token, longer or rarer words split into a few, and punctuation and whitespace each get their own token, then the model's published context window is a hard cap on that token count. That's why a word-count estimate is unreliable and running the actual text through a tokenizer is the only way to know for sure.
Why does one AI product advertise a character limit while another advertises a token limit?
+
They're measuring different things, and the two don't convert at a fixed rate. A character limit counts raw characters; a token limit counts tokenizer output, which varies by language and content. Comparing a '4,096 character' cap against a '128K token' cap directly is misleading; run the same text through each product's own tokenizer (or this tool's exact and estimated counts) before assuming one is more generous than the other.
Does my text fit in a 128K context window?
+
Paste it in and check the 128K bar in the context-window fit section: it shows the exact percentage that text fills for whichever OpenAI encoding is selected, or the Claude estimate before the exact tokenizer finishes loading. Under 100% means it fits; over 100% means you need to trim it or use a model with a bigger window.
Why don't the Claude, Llama 3, and Gemma counts match the exact GPT counts?
+
Because they aren't run through those models' real tokenizers. Claude's tokenizer isn't published, and Llama 3 and Gemma's real vocabularies are too large to load lazily in a browser tab, so this tool shows a rough characters-per-token estimate instead, clearly labeled Estimate rather than Exact. Treat those three rows as ballpark figures, not the number that model would actually bill or enforce.
How many tokens is my document?
+
Paste the whole document into the box above. You'll get an exact count for GPT-4o/GPT-4.1 and GPT-4/GPT-3.5, estimated counts for Claude, Llama 3, and Gemma, and a percentage fill for five common context-window sizes, all recomputed live as you edit, with nothing ever uploaded to see the answer.
Related tools
PII Redactor: Clean Text Before Pasting into AI
Paste text and redact emails, phone numbers, IPs, IBANs, card numbers, and API keys before sending it to ChatGPT or Claude. Nothing leaves your browser.
Can Your Mac Run It? LLM RAM Calculator
Check whether a model and quant will fit your Mac unified memory or GPU VRAM, with KV cache math, a max context solver, and a tokens per second estimate.
Local vs Cloud LLM Break-Even Calculator
Calculate whether a local LLM or a cloud API costs less per 1M tokens, including amortized hardware, power, and the break-even point.
GGUF Quant Decoder: What Does Q4_K_M Mean?
Type any GGUF quant name, like Q4_K_M or IQ4_XS, for a plain-English decode, plus a picker for which quant fits your memory.
Markdown Word Count & Reading Time
Count words and characters in markdown without frontmatter, code, or link syntax inflating the total, plus a per-heading breakdown and reading time.
This tool fixes one moment. recal handles the whole day.
recal is a private brain for your Mac. It watches how you work, on device, and starts doing your busywork itself. You approve every action.
Get early access