16-stage chat compressor · MIT · no account

Sixteen cuts.
Fewer tokens.
Same answer.

Paste a chat payload. Max Token Saver folds echoes, prefixes, tool dumps, and repeated context — in your browser. Nothing is uploaded. One file, zero dependencies, free to take.

File
12 KB
Stages
16
Login
None
A faceted crystal staff resting on a stack of paper in low light.
Safe by default. Tags stay self-describing. Referents stay in the payload.

Use it

Compress in the browser

Paste JSON, an OpenAI-style export, or role: lines. Compression never leaves this device.

Safety mode

The sixteen cuts

Each stage is a named cut

Safe mode keeps referents in the payload. Tags describe themselves. Lossy mode adds CheapGate and a tighter history zip — only when you ask for it.

  1. EchoFold

    01

    Drops a user turn that is mostly quoting the previous assistant message.

    The original assistant answer stays. The echo is gone.

  2. StickyPrefix

    02

    Lifts a repeated prefix into sticky:LINE and replaces later copies with ⟦sticky⟧.

    The prefix is stored once, in-payload.

  3. DeltaTurns

    03

    Writes later same-role turns as Δ+ from the shared prefix.

    The first full turn remains the referent.

  4. SemCache

    04

    Replaces duplicate long messages with ⟦dup:hash⟧.

    The first copy of the text stays.

  5. FuzzyHit

    05

    Marks near-copies as ⟦fuzzy:i⟧ of a kept original.

    The kept original is still in the payload.

  6. RoleMerge

    06

    Joins consecutive assistant or tool turns and strips exact repeated lines.

    User and system turns are never merged.

  7. JsonThin

    07

    Compacts JSON and drops nulls and empty strings.

    Non-JSON text is left alone.

  8. ToolTrim

    08

    Caps oversized tool bodies, keeping a head and a tail.

    A ⟦trim:n⟧ marker records the original length.

  9. HistZip

    09

    Replaces the middle of a long history with a short digest.

    JSON, code fences, the first turn, and the recent tail stay.

  10. TokBudget

    10

    Drops oldest non-system turns until a token budget is met.

    System notes and the latest turn are pinned.

  11. CheapGate

    11

    In lossy mode, keeps only the last few turns for short yes/no asks.

    Off by default. Safe mode never runs this.

  12. StopEarly

    12

    Cuts assistant or tool text at ---, long blank runs, or <|end|>.

    The answer before the cut remains.

  13. DedupCtx

    13

    Removes exact duplicate role + content turns.

    The first occurrence stays.

  14. FilePtr

    14

    Replaces large fenced code with a short preview and a file pointer.

    A preview of the first and last lines stays in the turn.

  15. BatchTwin

    15

    Merges two near-identical consecutive user asks.

    The longer of the two asks is kept, marked ⟦batch⟧.

  16. Whiteout

    16

    Collapses extra spaces and blank lines.

    Words are unchanged.

Learn

Three short films

Watch the cut, then do it in the playground. Captions are the tutorial; the picture is the mood.

Paste, compress, copy

  1. 01Paste a JSON array, an export with a messages field, or role: lines.
  2. 02Press Compress, or Control + Enter.
  3. 03Read the token drop. Copy or save the smaller payload.

How the sixteen cuts work

  1. 01Safe mode runs every stage except CheapGate.
  2. 02Each cut is tagged. The original text it points at stays in the payload.
  3. 03Open Advanced cuts to skip a stage, cap tools, or set a token budget.

Download one file and drop it in

  1. 01Get max-token-saver.js — 12 KB, no packages.
  2. 02Call saveTokens(messages) in Node or the browser.
  3. 03Ship the compressed messages to your model. Keep the dialect note so the model can read the tags.

Get the file

Open, free, one file

MIT licensed. No signup. No telemetry. Drop the script next to your chat client, or keep using this page.

Node
const mts = require("./max-token-saver.js");
const result = mts.saveTokens(messages, { mode: "safe" });
console.log(result.stats.saved, result.messages);
Browser
<script src="./max-token-saver.js"></script>
<script>
  const result = MaxTokenSaver.saveTokens(messages);
  // result.messages  result.stats.inTokens  result.stats.outTokens
</script>

Original compressor by JRS / @WallyX716. Safe by default: tags stay self-describing and referents stay in-payload. Token counts on this page are the library’s own estimate (characters ÷ 4).