Token Trimmer

Trim text to a target token count while preserving sentence boundaries.

Ad placeholder (leaderboard)

Token trimmer

When you need a chunk of text to fit inside a context window or a per-message budget, a hard character cut leaves you with an ugly half-sentence. This tool trims text to a target token count but always stops on a sentence boundary, so the result reads cleanly and never ends mid-thought.

How it works

The text is split into sentences. Starting from the top, the tool adds one whole sentence at a time, tracking a running token estimate, and stops just before the budget would be exceeded — keeping the last sentence that fully fits. Token counts use a characters-per-token heuristic selected by the tokenizer profile you choose (GPT-style, Claude-style, or code-heavy), which adjusts the ratio to match how that family packs characters. The before and after token estimates are shown so you can see exactly how much was removed.

Tips and notes

  • Budget for the rest of the message. Leave headroom for the system prompt, other context, and the model’s response — do not spend the whole window on one field.
  • Sentence-aware beats character cuts. Ending on a complete sentence keeps the meaning intact and avoids confusing the model with a dangling fragment.
  • Pick the matching profile. Code and JSON pack fewer characters per token than prose, so the code profile gives a closer estimate for those inputs.
  • Local and private. Nothing is uploaded, so trimming confidential text is safe.
Ad placeholder (rectangle)