Context Window Planner
Check whether a system prompt, retrieved documents, conversation history and expected output all fit — before the API rejects the request.
Token count is estimated (≈4 chars/token). Actual counts vary by model and tokenizer.
Paste text to visualize context usage
See how much of each model's window your text fills
The context window is a shared budget
A model's context window is the total for input and output together, not a limit on the prompt alone. Everything competes for the same space:
- The system prompt
- Tool and function schemas, serialised in full
- Conversation history, which grows every turn
- Retrieved documents
- The user's current message
- Room for the response
That last item is the one people forget. If the prompt consumes the entire window, there is no space to generate into, and you get either an error or a response truncated mid-sentence. Reserve the output budget first and plan the prompt around what remains.
Some providers count the reserved max_tokens against the window at request time rather than counting what is actually generated — so requesting a 4,000-token ceiling costs you 4,000 tokens of headroom whether or not the model uses them.
When the conversation outgrows the window
- Sliding window —Keep the system prompt and the most recent N turns, drop the oldest. Simple and effective for chat, but the model forgets earlier context entirely.
- Summarisation —Periodically replace old turns with a compact summary. Preserves the thread at the cost of an extra call and some fidelity loss.
- Retrieval over history —Store all turns, embed them, and retrieve only the relevant ones per request. Scales indefinitely and adds infrastructure.
- Structured state —Extract durable facts into an explicit state object and inject that rather than raw transcript. The most reliable approach for task-oriented agents.
- Reset with a handoff —Start a new conversation seeded with a written brief. Crude, and often the right answer for long agent runs.
About
The Context Window Visualizer shows how much of each major LLM's context window your text occupies. Paste any text — a document, a long conversation, a codebase — and see fill percentages across 12 models. Green bars mean plenty of room; amber means nearing the limit; red means the text is too long for that model. Also shows estimated input cost to process the text once.
How to use
- 1 Paste your text into the left textarea.
- 2 Token count, character count, and word count update instantly.
- 3 The right panel shows a fill bar for each model — green (<50%), amber (50–85%), red (>85%).
- 4 "Fits" or "Too long" badge indicates whether the text fits in that model's context window.
- 5 Input cost shows the estimated API cost to process this text once with each model.
- How accurate are the token estimates?
- This tool uses a ~4 characters per token heuristic (English prose). Actual token counts vary by model and content: GPT models use tiktoken (usually 3.5–4.5 chars/token for English), Claude uses byte-level BPE, Gemini uses SentencePiece. For exact counts, use the Token Counter tool with the gpt-tokenizer library.
- What does context window mean?
- The context window (also called context length) is the maximum number of tokens a model can process in a single request — including both the input (your prompt + conversation history) and the output (the model's response). Text longer than the context window must be chunked, summarized, or truncated.
- Why do some models have much larger context windows?
- Larger context windows require more memory (VRAM) during inference due to the KV cache, which stores key-value pairs for each attention head for every token. Long-context models use architectural innovations like sparse attention and ring attention to distribute the KV cache across hardware. As of 2026, 1M-token windows are standard for flagship models, and Llama 5 reaches 5M.
The full guide
More in AI Tools
See all ai tools.