Prompt Token Budget Calculator

A model's context window is one fixed pool of tokens, and everything in your prompt draws from it: the system instructions, the user's message, the conversation so far, every tool result an agent has accumulated, and the reply you are reserving space for. This calculator works top-down - you start with the window and decide how to split it, and it tells you what each share is worth in tokens, characters, turns and tool calls, before a single API call is made.

Private by design. Every calculation happens in your browser with JavaScript. Your prompts, transcripts and budget numbers never leave this page - nothing is uploaded, logged, or stored.

Model and estimation

Pick the model you are budgeting against (typical published values - override either number if your provider or local runtime differs), then set how densely your text packs into tokens and how much of the window to hold back.

Rough average; real tokenizers vary by a few percent either way, which is what the safety reserve covers.

Chat-template markers, role tags and tool schemas the API adds around your messages. Deducted from the window before allocation.

Start from a workload preset

Typical splits for four common shapes of LLM workload, as percentages of the usable window (instructions / user input / history / tool outputs / response). Adjust any bucket afterwards.

Allocate the window

Give each bucket a share of the usable window (after the reserve and template overhead). Shares that do not sum to 100% leave slack - shown in grey on the bar - or over-allocate, which the verdict flags.

BucketShare (%)TokensCharacter budgetWhat that buys

Your typical workload sizes

These convert the history and tool-output buckets into concrete capacity: how many conversation turns, or how many tool calls with results of that size, each bucket can actually hold.

A file read or API response usually lands between 1,000 and 8,000 characters.

Take the numbers with you

Copy a plain-text report for a design doc, download the CSV for a capacity spreadsheet, or share the exact setup by link.

What a prompt token budget is, and why you should set it on purpose

A large language model does not see your application as a chat log with sections; it sees one long string of tokens. The system instructions come first, then the user's current message and anything attached to it, then every prior turn of the conversation, then - in an agentic setup - each tool call and its result in the order they happened, and finally the space reserved for the new reply. All of that must fit inside one number: the model's context window. When the total crosses it, the API rejects the request with a "maximum context length exceeded" error, or a provider silently truncates the oldest messages and your agent starts forgetting what it already did.

Most people discover their budget by accident - they build a prompt, run it, and trim whatever fails. A token budget is the deliberate version of that: you decide in advance how much of the window each concern may spend, and you design each part to fit its share. The split matters more than the total. A chat assistant should give history the biggest slice; an agentic coder should give tool outputs the biggest slice, because every file read and command result accumulates until the task is done; a single-shot writer barely needs history at all. Two applications with identical windows can have completely different failure modes if they use the same split.

How the estimates are calculated

The calculator converts characters to tokens with a per-text-type ratio, because exact tokenization requires running the model's own tokenizer - that is what the LLM Token Counter on this site is for. The ratios below are the averages you will see in practice; the safety reserve (default 10%) exists precisely because the real count can land a few percent higher than the estimate.

Text profileChars per tokenTypical content
Plain English prose~4.0Chat messages, articles, support transcripts
Technical writing / mixed~3.6Docs with numbers, paths, identifiers interspersed
Code-heavy text~3.2Source code, JSON, logs - dense symbols tokenize finely
CJK (Chinese/Japanese/Korean)~1.8Each CJK character is usually its own token or a pair of them

The usable window is computed before any allocation happens: the context window, minus the safety reserve, minus the template overhead (the role markers, special tokens and tool schemas the API wraps around your messages - typically 20 to 100 tokens for a standard chat template, more once you register several tools). Each bucket's share of that usable window is its token budget, and the character budget is simply the token budget multiplied by the ratio. For history, a "turn" costs the average user message plus the average assistant reply converted to tokens; for tool outputs, one call costs its average result size the same way.

How to use this calculator

  1. Pick your model from the dropdown. The window and max-output fields pre-fill with typical published values; correct them if you run the model locally (a server started with a small context flag is smaller than the model's theoretical window) or behind a provider that truncates.
  2. Click the preset that matches your workload, then adjust the five percentage fields until the split reflects how you actually expect the prompt to be filled. If the shares do not sum to 100%, the grey slack on the bar is honest headroom - keep it if you are unsure.
  3. Set the text profile to your dominant content type. If your traffic is half code and half prose, pick the denser ratio: overestimating input tokens is the safe direction.
  4. Enter your typical workload sizes - average user message, average reply, average tool result. The table then tells you how many turns the history bucket holds and how many tool calls the tool-output bucket can absorb before the window fills.
  5. Check the response-headroom verdict. If your allocated reply space exceeds the model's max output, the provider will cap the reply at the limit anyway, and the excess allocation is wasted - raise the output limit, switch models, or shrink the bucket.
  6. Take the numbers with you: copy the text report into a design doc, download the CSV for a capacity spreadsheet, or copy the share link so your team reviews the exact same split.

A worked example

Take an agentic coding assistant on GPT-4o: a 128,000-token window, 16,384-token max output. With the default 10% reserve and 64 tokens of template overhead, the usable window is 128,000 × 0.9 − 64 = 115,136 tokens. Apply the Agentic coder preset (25 / 10 / 20 / 30 / 15):

  • Instructions - 25%: 28,784 tokens, about 115,000 characters at the prose ratio. Plenty for a detailed system prompt, coding conventions and tool descriptions.
  • User input - 10%: 11,513 tokens, roughly 46,000 characters - room for pasted stack traces and file snippets in the current message.
  • Conversation history - 20%: 23,027 tokens. At an average turn of 300 user characters plus 700 reply characters (250 tokens per turn), that holds about 92 turns - far more than most coding sessions, so the real constraint will be tool outputs, not chat.
  • Tool outputs - 30%: 34,540 tokens. At an average tool result of 2,000 characters (500 tokens), the agent can make about 69 tool calls before the window fills. That number is the one to watch: it is your agent's effective step budget.
  • Response headroom - 15%: 17,270 tokens - but the model caps output at 16,384, so the verdict flags that 886 allocated tokens can never be used. Either accept the cap or move a few points from instructions into headroom.

Common mistakes when budgeting prompt tokens

  • Budgeting the demo, not the production workload. A two-turn test fits any window. The failure is turn 40 of a support chat, or the agent's 50th file read. Budget history and tool outputs at your longest realistic session - the "turns that fit" and "calls that fit" columns exist precisely so you can see that number instead of discovering it as an error.
  • Forgetting that output is part of the window. The reply you reserve space for consumes context just like the prompt does. A high max-output setting silently shrinks your input budget by exactly that amount, and a provider cap can make part of your allocated headroom unreachable.
  • Letting tool outputs grow unbounded. In agentic loops every result stays in the window until the task ends. If your tool-output bucket is exhausted at call 30 but your tasks take 80 calls, you need summarization or truncation of old results - not a bigger window alone. A 200,000-token window that fills at call 60 still fails at call 81.
  • Trusting one tokenizer's count for another model. A prompt that is 100,000 tokens in one tokenizer may be 92,000 or 108,000 in another. That is what the safety reserve is for - and why a budget at 80-90% of the usable window is a good target, not 99%.
  • Mixing text profiles. Estimating a 24,000-character code file at the prose ratio (4.0 chars/token) undercounts it by about 25% - code tokenizes denser. When in doubt, use the code profile for anything with brackets and semicolons, and the CJK profile for Chinese, Japanese or Korean text.
  • Ignoring the runtime's actual limit. A locally served model may advertise a 128K window while the server was started with an 8K context. Enter what the runtime enforces - the calculator's verdict is only as good as the window number you type.

Privacy

This tool is entirely client-side. The allocation math, the character conversions and the exports all run in JavaScript inside your own browser tab, so your prompts, transcripts and budget numbers never touch a server. There is no account, no tracking of your inputs, and no data retention - close the tab and everything is gone.

Related tools

The rest of the LLM planning workflow:


Luke Keam
Spot a bug or want a custom utility built? I'd love to hear from you. Get in touch
Luke Keam | techgeek.biz