LLM context planning

Plan your AI context budget.

Plan token budgets for LLM requests, document chunks, and conversation history. Check what fits and reserve space for the answer. No model calls.

Browser-only calculationsTransparent formulasFree to use
View calculation ↓
01 / Your request

Give every token a place.

Use a custom capacity from your model documentation. The example is synthetic.

Manual token counts · no tokenizer loaded

Enter counts from your tokenizer or usage report. Character estimates are not exact token counts.

tokens
Total context window, including reserved output.
tokens
Leave blank if unknown; then the limit is unchecked.
AllocationWhole tokens
tokens
System and developer instructions
tokens
Retained messages from earlier exchanges
tokens
Definitions, results and message serialization
tokens
Documents or retrieved passages in this request
tokens
Space for the next generated answer
tokens
Explicit buffer for uncounted content

02 / Live calculation

Your context, accounted for.

Custom limits

Exactly at capacity

0tokens remaining

No headroom remains. Review overhead and safety margin before sending.

Total planned use32,000
Available source budget20,000After all other reserves

Window allocation

32,000 / 32,000 tokens
Instructions
2,000
History
4,000
Tools & overhead
1,000
Source text
20,000
Output reserve
4,000
Safety margin
1,000

Output maximum unknown: output-limit check is not performed.

A planning bound, not an API preflight guarantee. Use counts from the correct model tokenizer or provider usage report; message wrappers, reasoning and tools may need additional reserve.

03 / Compare a change

A small change. A clear difference.

Save a scenario above, then adjust a count to see the difference. Snapshots stay in this tab.

How to plan an AI context budget

A context window must hold the content in your request and the space reserved for the answer. This calculator adds your token allocations and shows the remaining capacity or overflow.

  1. Enter the context capacity from your model documentation and its output limit, if known.
  2. Allocate tokens to instructions, history, tools, source text, output and a safety margin.
  3. Check the result, save scenario A, and adjust your counts to compare a second plan.

Worked example

With 32,000 tokens of capacity and 12,000 allocated to everything except source text, the available source budget is 20,000 tokens.

This is a manual planning tool, not a tokenizer or an API preflight check. Model-specific wrappers, tools and reasoning may require additional reserve. Read the formulas and sources.