Skip to main content
UFOZoo

Context Window Calculator: 128k/1M Token Budget Planner

Context window calculator online: plan token budgets for 128k and 1M context windows, with usage share and compression tips.

Updated 2026-08-16

Related Tools

Features

  • Real-time token estimation powered by js-tiktoken (cl100k_base): the tokenizer family behind GPT-4-class models
  • Preset context windows: GPT-5.6 Luna 1M, Claude Sonnet 5 1M, Gemini 3.6 Flash 1M, and Grok 4.20 2M, plus 128k/200k tiers and a fully custom window size
  • Honest Chinese estimation: CJK text is estimated at 1.5-2 tokens per character, and the estimate is clearly labeled as an approximation
  • Message-usage progress bar: see exactly what percentage of the context window your text occupies at a glance
  • Remaining-space readout: know how many tokens are left before the window overflows
  • Rule-based compression tips: detect overly long lists, duplicate lines, example overload, and unstructured walls of text
  • Estimated savings range for every suggestion, so you can judge whether rewriting is worth the effort
  • Text-to-budget conversion: answers how much text fits in a 128k or 1M window in Chinese characters and English words
  • Multi-message mode: paste one message per line and see each message's share of the window plus the cumulative total
  • Character, word, and line counts alongside the token count for a complete picture of the text size
  • Fully client-side: your prompts and code never leave the browser

How to Use

  1. 1Paste or type your text into the input area. The token count, character count, and word count update instantly as you type.
  2. 2Pick a model preset button to set the context window: GPT-5.6 Luna 1M, GPT-5.3 Chat 128k, Claude Sonnet 5 1M, Claude Opus 4.5 200k, Gemini 3.6 Flash 1M, DeepSeek V4 Flash 1M, or Grok 4.20 2M.
  3. 3Choose Custom and enter your own window size, handy for models with unusual context limits or when you want to budget only part of the window.
  4. 4Watch the progress bar: under 50% is safe, 50-80% is a warning, 80-100% is danger, and past 100% your text no longer fits.
  5. 5Plan whether a long document fits: paste a draft article, report, or spec and check its share of the window before sending it to the model.
  6. 6Evaluate conversation history: paste an entire chat log to see how much of the context window the back-and-forth consumes, then trim the oldest rounds.
  7. 7Estimate API cost budget: multiply the token count by your provider's per-1M-token price to estimate what a single call will cost.
  8. 8Enable Multi-message mode and put one message per line. Each line gets its own token count, percentage, and cumulative total.
  9. 9Read the compression tips below the results: they flag long lists, duplicate lines, too many examples, and unbroken walls of text, with an estimated token saving.
  10. 10Try the example buttons (Long Article, Chat Log, Code Snippet) to see how different kinds of content consume a 128k window.

Frequently Asked Questions

How many words fit in a 128k or 1M context window?

Roughly: English runs about 0.75 words per token, and Chinese about 1.5-2 characters per token. A 128k window fits roughly 90,000-100,000 English words or about 65,000-85,000 Chinese characters. A 1M window fits roughly 700,000-750,000 English words or about 500,000-670,000 Chinese characters. These are estimates: exact numbers depend on the text and the model's tokenizer.

How is the token count calculated?

English and code are encoded with js-tiktoken using the cl100k_base tokenizer, the same family used by GPT-4-class models, so those counts are close to the real API values. Chinese is estimated by character count at 1.5-2 tokens per character, which is an approximation, not an exact count. The estimate note under the results says which method was used.

How accurate are the estimates for different models?

For OpenAI models (cl100k/o200k tokenizer families, GPT-4 through GPT-5) the English/code counts are very close to what the API reports. Claude, Gemini, and DeepSeek use different tokenizers, so their real counts can differ by a few percent. Chinese estimates carry more uncertainty because they use an experience-based conversion rather than a real tokenizer.

What happens when the context window is full?

Text beyond the window cannot be processed. Depending on the provider and how you call the model, the excess is either rejected or silently truncated, and in multi-turn conversations the model effectively forgets the earliest messages first. Budgeting below the limit is the only reliable way to avoid this.

How do the model context windows compare?

GPT-5.6 Luna has a 1M window, GPT-5.3 Chat a 128k window, Claude Sonnet 5 a 1M window, Claude Opus 4.5 a 200k window, Gemini 3.6 Flash a 1M window, and Grok 4.20 a 2M window. A bigger window is not always better: longer contexts usually cost more per call and can make the model pay less attention to the middle of the input.

Are the compression tips reliable?

They are rule-based heuristics: the tool counts list items, duplicate lines, example markers, and paragraph structure, then suggests a plausible saving range. The ranges are rough estimates: the actual saving depends on your content. Treat them as hints, not guarantees.

Can I use this to estimate API costs?

Yes, as a starting point: multiply the token count by the provider's price per 1M tokens. But pricing varies by model, region, cache hits, and discount tiers, so you should check the official pricing page for your exact rate. This tool deliberately does not bundle prices, because they change often.

How do I use multi-message mode?

Toggle Multi-message on and put one message per line in the input area. The table below the progress bar shows each message's token count, its percentage of the window, and the running cumulative total. This mirrors a real chat request, where system prompt, history, and user message all share one window.

Why do English and Chinese token counts differ so much?

English averages about 4 characters per token (roughly 0.75 words), while Chinese needs 1.5-2 tokens per character. The same content in Chinese therefore costs noticeably more tokens, which also means higher API cost for Chinese prompts.

How does the context window relate to VRAM?

For API models (GPT, Claude, Gemini) there is no direct link. VRAM lives on the provider's servers. For local models (Ollama, llama.cpp), the KV cache grows with context length and can exhaust GPU memory, which is why local deployments often cap the context window below the model's nominal maximum. This tool budgets tokens and text, not VRAM. For local use, check your model's context setting against your GPU memory.

What is Claude's current context window size?

As of this snapshot the presets cover Claude Sonnet 5 at 1M tokens and Claude Opus 4.5 at 200k tokens. Limits change with model releases and can differ by plan or API tier, so verify the current numbers in Anthropic's official documentation before budgeting a production call.

What percentage of the window should I aim for?

Leave room for the model's reply: output tokens also consume the window. For long-running conversations, staying under 50-70% is a sensible target so the model has space to respond and you keep a buffer against tokenizer differences.

My prompt is too long. What should I cut first?

Cut the oldest conversation turns first: they are least relevant to what you are asking now. Then remove duplicated examples and verbose system instructions: one representative example beats three near-identical ones. If the history is genuinely useful, replace it with a one-paragraph summary instead of deleting it. The compression tips on this page flag the exact candidates (long lists, duplicate lines, example overload) with an estimated saving.

Long chats keep overflowing the window. How do I reset without losing context?

Use the summarize-and-continue flow: ask the model to condense the conversation into a short summary that records decisions, constraints, and open questions, paste that summary back as the new opening message, and continue in a fresh window. This page can estimate the summary's token cost before you commit. If it is under 10% of the window, you have plenty of room for the conversation ahead.

My estimated token count doesn't match the API bill. How big is the error?

For English and code, the cl100k_base estimate is typically within a few percent of what OpenAI's API reports, so billing-level differences there are small. Chinese is the weak spot: the 1.5-2 tokens-per-character conversion is an experience-based guess, and real counts can differ by 20-30%, which on a long document is thousands of tokens. For exact numbers, use the model's own tokenizer (tiktoken) before committing to a cost estimate.

I selected the wrong model preset. Does the estimate still mean anything?

The token count itself does not change (tokenizers are similar across the presets), but the percentage and the progress bar do, because they divide by the preset's window size. Pick 128k when the number says 128k; if you used a custom window, re-enter the exact size. If you only care about the raw token count, the preset barely matters; if you care about budget fit, it decides whether you are at 40% or 90% of the window.