Paste, compress, copy
- 01Paste a JSON array, an export with a messages field, or role: lines.
- 02Press Compress, or Control + Enter.
- 03Read the token drop. Copy or save the smaller payload.
16-stage chat compressor · MIT · no account
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.

Use it
Paste JSON, an OpenAI-style export, or role: lines. Compression never leaves this device.
Control + Enter to run
The sixteen cuts
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.
Drops a user turn that is mostly quoting the previous assistant message.
The original assistant answer stays. The echo is gone.
Lifts a repeated prefix into sticky:LINE and replaces later copies with ⟦sticky⟧.
The prefix is stored once, in-payload.
Writes later same-role turns as Δ+ from the shared prefix.
The first full turn remains the referent.
Replaces duplicate long messages with ⟦dup:hash⟧.
The first copy of the text stays.
Marks near-copies as ⟦fuzzy:i⟧ of a kept original.
The kept original is still in the payload.
Joins consecutive assistant or tool turns and strips exact repeated lines.
User and system turns are never merged.
Compacts JSON and drops nulls and empty strings.
Non-JSON text is left alone.
Caps oversized tool bodies, keeping a head and a tail.
A ⟦trim:n⟧ marker records the original length.
Replaces the middle of a long history with a short digest.
JSON, code fences, the first turn, and the recent tail stay.
Drops oldest non-system turns until a token budget is met.
System notes and the latest turn are pinned.
In lossy mode, keeps only the last few turns for short yes/no asks.
Off by default. Safe mode never runs this.
Cuts assistant or tool text at ---, long blank runs, or <|end|>.
The answer before the cut remains.
Removes exact duplicate role + content turns.
The first occurrence stays.
Replaces large fenced code with a short preview and a file pointer.
A preview of the first and last lines stays in the turn.
Merges two near-identical consecutive user asks.
The longer of the two asks is kept, marked ⟦batch⟧.
Collapses extra spaces and blank lines.
Words are unchanged.
Learn
Watch the cut, then do it in the playground. Captions are the tutorial; the picture is the mood.
Get the file
MIT licensed. No signup. No telemetry. Drop the script next to your chat client, or keep using this page.
const mts = require("./max-token-saver.js");
const result = mts.saveTokens(messages, { mode: "safe" });
console.log(result.stats.saved, result.messages);<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).