</>CodeScrub

LLM Context Window Planner

Budget your system prompt, history, data, and output — see what fits.

Model128K context · 16K max output
GPT-4o · 128,000 tokens
Presets
Context window1,000 / 128,000 (0.8% used)

127,000 tokens remaining after all sections

System Prompt
0 · 0.0%
Conversation History
0 · 0.0%
Data / Context
0 · 0.0%
Expected Output
1,000 · 0.8%
System Prompt
0 tokens(0.0%)
Conversation History
0 tokens(0.0%)
Data / Context
0 tokens(0.0%)
Expected Output
1,000 tokens(0.8%)
1,000
100~750 words16,384 max
Recommendations
Plenty of room. 127,000 tokens remaining after all sections.

Optimize further

Use TOON format for data payloads to reduce tokens by 30–60% JSON ↔ TOON Converter

Count your actual tokens precisely (exact tokenization for OpenAI models) Token Counter

Structure system / user / assistant messages for the API Prompt Formatter

· If you're consistently near the limit, consider a model with a larger context window (GPT-4.1 at 1M, Gemini 2.5 Pro at 1M, Llama 4 Scout at 10M).

Ad space · context-planner-mid

What Is an LLM Context Window?

The context window is the maximum number of tokens a language model can process in a single request. That total includes everything: your system prompt, the conversation history you send, any data you inject (retrieved chunks, JSON payloads, documents), and the model's own response. Exceed the window and the model either truncates the input or returns an error — neither is fun to debug. Planning the budget before you build avoids the surprise.

Context Window Sizes by Model (mid-2026)

ModelContext windowMax output
GPT-4o128K16K
GPT-4.11M32K
Claude Sonnet 4200K32K
Claude Opus 4200K32K
Gemini 2.5 Pro1M65K
Llama 4 Scout10Mvaries

These figures are approximate as of mid-2026 and may have changed since. Check your provider's current docs for exact limits.

How to Budget Your Context Window

  1. System prompt — keep it under 500 tokens if you can. Every token here is consumed on every request, so a bloated system prompt scales your bill linearly with call volume.
  2. Conversation history — grows with each turn. Implement a sliding window that drops the oldest turns once you cross a threshold, or summarize earlier turns into a single compressed message.
  3. Data / context — RAG chunks, retrieved documents, structured payloads. This is typically the biggest and most variable section. Compress structured data with a token-efficient format like TOON — it saves 30–60% on uniform-shape data with no loss.
  4. Output— reserve enough room for the response you actually expect. If the user asks for "a detailed analysis," budget 2,000–4,000 tokens; if you're classifying to a single word, 100 is plenty.

Related Tools

Privacy

Your text stays in your browser. Tokenization runs entirely client-side; nothing is sent to any server or API.