Context Trimmer

Trim long text to an approximate LLM token budget while choosing whether to keep the start, end, middle, or both ends.

Try:
Trimmed text

About this tool

Context Trimmer shortens text so it fits an approximate LLM token budget. It is useful when you need to paste a long log, transcript, prompt, article, or chat-history excerpt into a model with a fixed context window.

The tool uses a simple, transparent estimate: tokens ≈ characters ÷ characters per token. The default is 4.0 characters per token, a common English rule of thumb. Lower the value for code or non-English text when you want a more conservative trim.

Worked example

Input:

the quick brown fox jumps over the lazy dog

Settings: max_tokens = 5, chars_per_token = 4.0, keep = head_tail, marker .

Output:

the quick…lazy dog

The marker counts toward the budget, so the final result still fits the target estimate.

Keep strategies

Limits

FAQ

Does this use the same tokenizer as GPT, Claude, or Llama?

No. It intentionally uses a transparent approximation: characters divided by the Characters per token value. Use a lower value for more conservative trimming when exact model-token fit matters.

Which keep mode should I choose for logs or stack traces?

Use Head + tail for logs, stack traces, and command output. The beginning often has setup context, while the end usually contains the failure. Use Tail when only the latest messages matter.

Why does the output sometimes use fewer tokens than the target?

When word-safe trimming is enabled, the cut backs up or moves forward to a whitespace boundary so it does not split words. That can leave a little unused budget. Turn on Allow cutting inside words for stricter character use.

Is the text uploaded anywhere?

No. The trim runs locally in your browser with WebAssembly; your text stays on your device.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool context-trimmer "Paste the long text, prompt, log, transcript, or document here…"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/context-trimmer/?text=Paste%20the%20long%20text%2C%20prompt%2C%20log%2C%20transcript%2C%20or%20document%20here%E2%80%A6&max_tokens=512&chars_per_token=4.0&keep=head&marker=%E2%80%A6&head_ratio=0.5&break_words=true

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.