LLM Context Window Calculator
Check whether your prompt, document or book fits in a model's context window. Enter tokens, words or pages, reserve room for the reply, and see which models fit, how much space is left and the KV cache memory that context needs on open-weight models.
Your content
Sets the tokens per word. Ignored when the unit is tokens.
500 is a single-spaced page, 250 is double-spaced.
The window holds the prompt and the answer together, so leave room for the output. Reasoning models count thinking tokens too.
Does it fit?
Your content is about 100,000 tokens (about 150 pages). With 4,096 reserved for the reply that is 104,096 tokens in total. The smallest listed window that holds it is Llama 3.1 8B (131,072 tokens).
| Model | Window | Used | Tokens left | Fits? |
|---|---|---|---|---|
| GPT-6.1 TerraOpenAI | 1,050,000 | 9.9% | 945,904 (about 1,419 pages) | Yes |
| Claude Sonnet 5.5Anthropic | 1,000,000 | 10.4% | 895,904 (about 1,344 pages) | Yes |
| Gemini 3.1 ProGoogle | 1,048,576 | 9.9% | 944,480 (about 1,417 pages) | Yes |
| Llama 3.1 8BOpen weights | 131,072 | 79.4% | 26,976 (about 40 pages) | Yes |
| Llama 3.1 70BOpen weights | 131,072 | 79.4% | 26,976 (about 40 pages) | Yes |
| Llama 3.1 405BOpen weights | 131,072 | 79.4% | 26,976 (about 40 pages) | Yes |
| Mistral 7B v0.3Open weights | 32,768 | 318% | over by 71,328 | No |
| Qwen 2.5 7BOpen weights | 32,768 | 318% | over by 71,328 | No |
| Qwen 2.5 32BOpen weights | 32,768 | 318% | over by 71,328 | No |
| Qwen 2.5 72BOpen weights | 32,768 | 318% | over by 71,328 | No |
| Gemma 2 9BOpen weights | 8,192 | 1271% | over by 95,904 | No |
| Gemma 2 27BOpen weights | 8,192 | 1271% | over by 95,904 | No |
| DeepSeek R1 Distill Llama 8BOpen weights | 131,072 | 79.4% | 26,976 (about 40 pages) | Yes |
| DeepSeek R1 Distill Qwen 32BOpen weights | 131,072 | 79.4% | 26,976 (about 40 pages) | Yes |
Hosted limits (checked November 23, 2026) come from the provider pages: GPT-6.1 Terra, Claude Sonnet 5.5, Gemini 3.1 Pro. Providers change limits and some charge more above a size threshold, so confirm before you build on a number.
Memory for that context (open-weight models)
Running a model locally, the KV cache grows with every token in the window. For 104,096 tokens at FP16, batch 1:
| Model | KV cache | Note |
|---|---|---|
| Llama 3.1 8B | 12.7 GB | |
| Llama 3.1 70B | 31.8 GB | |
| Llama 3.1 405B | 50.0 GB | |
| Mistral 7B v0.3 | 12.7 GB | Exceeds the 32,768-token window |
| Qwen 2.5 7B | 5.56 GB | Exceeds the 32,768-token window |
| Qwen 2.5 32B | 25.4 GB | Exceeds the 32,768-token window |
| Qwen 2.5 72B | 31.8 GB | Exceeds the 32,768-token window |
| Gemma 2 9B | 33.4 GB | Exceeds the 8,192-token window |
| Gemma 2 27B | 36.5 GB | Exceeds the 8,192-token window |
| DeepSeek R1 Distill Llama 8B | 12.7 GB | |
| DeepSeek R1 Distill Qwen 32B | 25.4 GB |
This is the cache only, on top of the model weights. Add weights and overhead and check GPU fit with the LLM RAM and VRAM calculator, or change precision, batch size and attention type in the KV cache calculator.
How to check if your text fits a context window
- Enter the size of your content and pick its unit. If you already have an exact token count, choose Tokens. If not, use words, pages or books and pick the language.
- Set how many tokens to reserve for the reply. The context window covers the prompt and the output together.
- Read the table: models marked Yes can take the prompt and the reply. Tokens left shows the headroom, with the same amount expressed in pages.
- For a model you run yourself, check the KV cache table, then add the weights with the RAM calculator.
How it is calculated
- Fits when prompt tokens + reserved output tokens ≤ the context window. Anything over is shown as the number of tokens to cut.
- Words and pages to tokens use about 1.33 tokens per English word (0.75 words per token) and the per-language ratios from the tokens to words converter. A page is 500 words by default, a book 80,000 words (about 107,000 tokens). These are estimates, so for exact counts use a tokenizer.
- KV cache = 2 × layers × KV heads × head dimension × 2 bytes (FP16) × tokens, from each model's
config.json. - Open-weight windows are the maximum position length in the model config. Qwen 2.5 is 32,768 natively and reaches 131,072 only with YaRN scaling enabled.
Worked example
A 300-page contract at 500 words a page is 150,000 words, about 200,000 tokens. With 4,096 reserved for the answer it needs roughly 204,000 tokens: too big for the 131,072-token Llama 3.1 models, fine for the 1M-token hosted models at about 20% of the window.
For an exact token count of your own text and the API price, use the AI tokens calculator.
Updated November 19, 2026. Not financial advice. This calculator is for education and rough estimates only. It relies on simplified models and your inputs, ignores taxes and many real-world costs, and past or modelled results do not guarantee future outcomes. Consult a licensed professional before making financial decisions.
See also
- Count the tokens in your own text and see the API cost with the AI tokens calculator.
- Convert between tokens, words, pages and books with the tokens to words converter.
- Size the cache for any model, precision and batch size with the KV cache calculator.
- Add the model weights and find a GPU that fits with the LLM RAM and VRAM calculator.
Frequently Asked Questions (FAQ)
The context window is the maximum number of tokens a model can handle in one request. It holds everything together: your instructions, any documents or chat history you send, and the reply the model writes. If the total goes over the limit, the request fails or older content is dropped.
At about 1.33 tokens per English word and 500 words per page, a page is roughly 667 tokens. A 128K (131,072-token) window holds about 196 pages and a 1M window about 1,500 pages, before leaving room for the reply. Double-spaced pages of 250 words are half the size, so twice as many fit.
Yes. Input and output share the window, so a 200,000-token prompt in a 200,000-token window leaves nothing for an answer. Many models also cap the reply separately, for example 64K to 128K tokens, and reasoning models count their thinking tokens against the window.
For English, multiply words by about 1.33, or divide tokens by 0.75 to get words. Other languages use more tokens per word: about 1.5 for Spanish, 1.7 for German and 2.5 for Turkish. This calculator does the conversion for you. For an exact count of your own text, use the AI tokens calculator.
On models you host yourself, yes. The KV cache grows linearly with the number of tokens: Llama 3.1 8B needs 128 KiB per token at FP16, so 8,192 tokens take 1 GiB and a full 131,072-token window takes 16 GiB, on top of the weights. Hosted APIs handle this for you, but long prompts usually cost more and respond more slowly.
Common reasons: the reply budget plus prompt is over the limit; the server is configured with a smaller context than the model supports (many local runtimes default to 2K to 8K tokens); there is not enough GPU memory for the KV cache; or the model only reaches its long context with a scaling setting such as YaRN turned on.
Trim the input, summarize older parts, split the document into chunks and process each one, or use retrieval (RAG) so only the relevant passages are sent. You can also move to a model with a larger window. Chunk size and embedding cost can be estimated with the RAG chunking calculator.
The hosted model limits were checked on the date shown under the table, with links to each provider page. Providers change limits, offer larger beta windows and sometimes charge more above a size threshold, so confirm the number in the provider documentation before you rely on it.
Not always. Models tend to use information in the middle of a very long prompt less reliably, cost grows with every input token, and latency rises with prompt length. Sending only what the model needs is usually cheaper and often more accurate than filling the window.
Related Tools
- LLM VRAM CalculatorEstimate how much GPU memory (VRAM) you need to run a local LLM, and which GPUs can run it.
- KV Cache CalculatorMemory per token and total KV cache from layers, KV heads, head dimension, context, batch and precision, with GQA and context-length views.
- LLM Tokens per Second CalculatorEstimate local LLM generation speed from GPU memory bandwidth, model size and quantization.
- Self-Host vs API Cost Calculator (LLM Break-Even)Compare monthly LLM API cost with self-hosting on a rented or owned GPU and find the break-even token volume. All assumptions shown.
- GPU Rental Cost CalculatorEstimate cloud GPU cost per job and per month from hourly rate, GPU count, job and idle hours, storage and egress. Example rates are dated and editable.
- LLM Training Cost CalculatorEstimate LLM training or fine-tuning compute, GPU-hours and dollar cost from parameters, tokens, epochs, GPU type and utilisation using the 6 × N × D rule of thumb.