Context Window Planner
Check whether your prompt, history and context fit a model's window.
For the “Short chat” scenario, Fits within the context window — 1,100 / 128,000 input tokens used (0.9%). Enter your own numbers below to recompute instantly; the full step-by-step math is shown under the worked example.
Results update automatically as you type.
- System prompt
- 400 tokens
- Conversation history
- 2,000 tokens
- Retrieved / context
- 3,000 tokens
- User message
- 200 tokens
- Total input
- 5,600 tokens
- Context window
- 128,000 tokens
- Remaining
- 122,400 tokens
Plan your prompt against a model's context window. Add up your system prompt, conversation history, retrieved context, user message, and desired output, and instantly see whether it all fits and how much room is left.
How this is calculated
We sum your system prompt, conversation history, retrieved/context tokens, user message and desired output, then compare the total to your model's context window to show whether it fits and how many tokens remain. Everything you send plus the output you want has to live inside that one window.
Is this a good result? What to do next
A plan that fits with comfortable headroom is healthy; one near the ceiling is fragile — a slightly longer answer or one extra retrieved chunk can push it over. Retrieved context and history are usually the biggest, most compressible slices.
Typical planning ranges
- Reserve for output
- subtract desired output first
- Biggest slices
- retrieval + history
- Near-ceiling plans
- fragile — trim or upgrade
Ranges are typical planning figures to sanity-check your result, not authoritative benchmarks. Your numbers will vary with use case, volume, and vendor.
How to improve this number
- Retrieve fewer/tighter chunks; trim or window history.
- Cache a stable system prompt so it doesn't crowd the budget.
- Choose a larger-context model for RAG-heavy or long-document work.
Common mistakes
- Forgetting the output reservation eats into the window.
- Planning to the exact limit with no safety margin.
When to use a different approach
For a quick percentage read, use the context window usage calculator; to test one document, use the 'will it fit' checker.
Worked examples
Real scenarios you can reproduce by loading these presets in the calculator above:
Short chat
- System prompt
- 400 tokens
- Conversation history
- 500 tokens
- Retrieved / context
- 0 tokens
- User message
- 200 tokens
- Total input
- 1,100 tokens
- Context window
- 128,000 tokens
- Remaining
- 126,900 tokens
- used% = total input / context window = 0.9%
RAG-heavy
- System prompt
- 400 tokens
- Conversation history
- 1,000 tokens
- Retrieved / context
- 20,000 tokens
- User message
- 200 tokens
- Total input
- 21,600 tokens
- Context window
- 128,000 tokens
- Remaining
- 106,400 tokens
- used% = total input / context window = 16.9%
Long document
- System prompt
- 400 tokens
- Conversation history
- 2,000 tokens
- Retrieved / context
- 100,000 tokens
- User message
- 200 tokens
- Total input
- 102,600 tokens
- Context window
- 128,000 tokens
- Remaining
- 25,400 tokens
- used% = total input / context window = 80.2%
Frequently asked questions
What is a context window?+
It is the maximum number of tokens a model can consider at once, including everything you send plus (usually) the tokens it generates.
What happens if I exceed the context window?+
The API rejects the request or truncates content. Fit more by trimming history, retrieving fewer chunks, or choosing a model with a larger window.
Related calculators
Answering a real question?
This calculator powers these problem-solving guides: