Cut your LLM token costs. Keep every word that matters.
Named after the Spartans of Laconia — when Philip II threatened "If I invade Laconia, I will raze Sparta," they replied: "If."
You're feeding markdown into GPT-4, Claude, or Gemini. But up to 50% of your tokens are going to things the model doesn't need:
[](https://github.com/org/repo/actions)
[](https://codecov.io/gh/org/repo)
<div style="padding: 20px; background: #f5f5f5; border-radius: 8px">
<table border="1" cellpadding="8">
<tr><th style="text-align:left">Config</th><th>Value</th></tr>
<tr><td>timeout</td><td>30s</td></tr>
<tr><td>retries</td><td>3</td></tr>
</table>
</div>That's 96 tokens of badges, HTML wrappers, and table formatting. The LLM needs 9:
Config,Value
timeout,30s
retries,3
Laconic does this automatically. Zero config. Zero semantic loss. Sub-millisecond.
git clone https://github.com/copyleftdev/laconic.git
cd laconic
cargo build --release
cp target/release/laconic /usr/local/bin/# Compress a file
laconic compress README.md
# Fast mode (skip token counting)
laconic compress -f README.md
# Estimate savings across a directory
laconic estimate docs/**/*.md
# Pipe from stdin, JSON output
cat prompt.md | laconic compress -j -Compressed text goes to stdout. Stats go to stderr. Pipes cleanly.
| Document Type | Savings | Example |
|---|---|---|
| HTML-heavy docs (React, Angular) | 40–55% | Component libraries, Storybook exports |
| Awesome-lists | 20–30% | Badge-heavy curated lists |
| API documentation | 15–25% | Table-heavy references, OpenAPI rendered docs |
| READMEs | 10–15% | Typical open-source project READMEs |
| Pure prose | 0% | Blog posts, essays — Laconic never touches meaning |
laconic compress README.md # compress to stdout
laconic compress -f docs/*.md # fast, no token stats
laconic estimate --json docs/**/*.md # audit token spenduse laconic_core::{compress, compress_text, CompressConfig};
// Full stats
let result = compress(&markdown, &CompressConfig::default());
println!("Saved {} tokens ({:.1}%)", result.tokens_saved, result.savings_pct);
// Fast path — just the text, no token counting
let compressed = compress_text(&markdown, &CompressConfig::default());Any MCP-compatible client — Windsurf, Cursor, Claude Desktop — can call Laconic as a tool:
{
"mcpServers": {
"laconic": {
"command": "laconic-mcp",
"args": []
}
}
}The agent gets two tools:
compress_markdown— compress and return text + token statsestimate_savings— check if compression is worth it before committing
Eight lossless strategies, applied in sequence:
| Strategy | What It Removes | Toggle |
|---|---|---|
| Whitespace | Extra blank lines, trailing spaces | Always on |
| Badges | Shield.io / badge images | --no-badges |
| HTML Tables | <table> blocks → CSV |
--no-html |
| HTML Cleanup | <div>, style="", align="" |
--no-html |
| Markdown Tables | Pipe tables → CSV | --no-tables |
| Code Fences | Common leading indentation | Always on |
| Headings | Trailing # characters |
Always on |
| URL Dedup | Repeated inline URLs → references | --url-dedup |
Guarantees:
- Idempotent —
compress(compress(x)) == compress(x) - Never inflates — output tokens ≤ input tokens, always
- Deterministic — same input always produces the same output
- No panics — tested across hundreds of real-world files
| Laconic | LLMLingua-2 | |
|---|---|---|
| Type | Lossless (syntactic) | Lossy (linguistic) |
| Fidelity | 100% | ~94% SBERT similarity |
| Speed | Sub-millisecond | 100ms–2s per doc |
| Dependencies | None (5.6MB binary) | Python + PyTorch + 300MB model |
| Best for | Structure-heavy docs | Prose compression |
They stack. Run Laconic first (fast, free), then LLMLingua-2 on the result.
Full user guide with recipes for RAG pipelines, CI/CD integration, and token budgeting:
MIT