open source · MIT · lossless

Fit 5× more in your context. Lose nothing.

Densely packs logs, JSON, tool outputs and code into 2×–8× fewer tokens — with guaranteed byte-exact reconstruction, verified by sha256 on every decompress. Nothing is summarized. Nothing expires. Nothing is ever dropped.

$ pip install densely
Join Pro waitlist →
claude code · densely hook active
$ densely compress deploy.log
in 184,392 bytes · 48,127 tokens
out 6,934 tokens 6.94× · 85.6% fewer
sha256 9f2c…e41a ✓ verified
$ densely expand deploy.log.dense | sha256sum
9f2c…e41a ✓ byte-exact match
⎿ tokens saved today: 312,480
6.94×
logs — 85.6% fewer tokens
7.75×
JSON tool outputs — 87.1% fewer
7.27×
code, neural backend — 86.3% (2.02× with lzma)
100%
byte-exact recovery, sha256-verified — always
every number reproducible: python bench.py
// how it works

A token can carry ~17.6 bits. Typical text uses 5–6.

Densely reclaims the difference. Compressed bytes are re-encoded as a stream of 65,536 single-token English words — the o200k pre-tokenizer never merges across word boundaries, so every carrier word costs exactly one token and carries two bytes of compressed data. That's 16 of the ~17.6 available bits: 91% of channel capacity.

text
logs, JSON, code, anything
lzma
standard lossless compression
16-bit chunks
two bytes per symbol
65,536 words
one token each — 2 bytes per token
Decompression reverses the pipeline and checks sha256 against the original. A mismatch is an error, never a silent corruption.
// what you get
Automatic mode

A hook compresses every large tool output on the fly — no workflow changes. A savings ledger shows tokens saved today and this week, so the effect on your usage cap is visible, not vibes.

MCP server

Works in Claude Code and Cursor today: compress_file, search, expand. The agent searches inside compressed payloads and expands exact slices — without inflating the whole thing back into context.

CLI & Python library

pip install densely, three commands. Compressed payloads are plain text: they survive context compaction, session export, and machine moves. No cache, no TTL, nothing to expire.

Neural backend

Qwen2.5-Coder + arithmetic coding pushes code from 2.02× to 7.27× — 86.3% fewer tokens, still byte-exact. A record for lossless compression on code.

// an honest comparison

Lossy-but-readable vs lossless-but-unreadable

Tools like Headroom keep compressed content readable by the model — by selecting what to keep. Densely keeps every byte — but the payload is opaque until expanded. Different trade, different jobs.

densely
headroom
approach
Entropy coding — lzma or neural, re-encoded as single-token words
Statistical selection — keeps what matters, drops redundancy
model reads it inline
No — opaque until expanded or searched via tools
Yes — compressed output stays human- and model-readable
reconstruction
Byte-exact, sha256-verified on every decompress
Reversible via cache retrieval; representation itself is lossy
typical ratio
6.9–7.8× on logs and JSON; 2–7.3× on code
60–95% on JSON; 15–20% for coding agents
expiry
None — payloads are portable text, no cache, no TTL
Originals live in a cache with retrieval on demand
best for
Exact data that must survive: traces, configs, session export
Context the model should keep reading, cheaper
// no magic

When it saves — and when it doesn't

✓ saves
Large tool outputs, logs, and JSON your agent needs later but not now
Exact data that must survive compaction — stack traces, configs, IDs, diffs
Session export and machine moves — payloads are portable text
Reference material the agent can search without expanding
✗ doesn't
Content the model must read inline on every turn — compressed payloads are opaque until expanded
Small snippets — fixed overhead eats the savings below a few hundred tokens
Already-dense prose — expect ~2×, not 7×
Shannon still applies: nothing compresses below its entropy

Stop paying for air.

Open source, MIT, runs locally. Benchmarks ship with the repo.

$ git clone github.com/alibaizhanov/densely
★ Star on GitHub
densely pro

Managed proxy, team savings dashboard, cloud neural compression. Coming soon.

Join the waitlist →