Logs, JSON, and CSV repeat the same structure on every row. ctxfold folds the repetition into a one-time header and keeps only what varies — cutting LLM prompt tokens without dropping a byte.
$ npm install ctxfold
github.com/antrixy/ctxfold →
2026-06-26T07:26:48.730Z ERROR [billing] reqId=1898747 token validated latency_ms=736 status=500 2026-06-26T07:26:49.104Z ERROR [billing] reqId=1898748 card declined latency_ms=812 status=402 2026-06-26T07:26:49.377Z ERROR [billing] reqId=1898749 retry scheduled latency_ms=95 status=202
cols: time level scope reqId latency_ms status message
07:26:48.730 ERROR billing 1898747 736 500 token validated
07:26:49.104 ERROR billing 1898748 812 402 card declined
07:26:49.377 ERROR billing 1898749 95 202 retry scheduled
v0.2.0
ctxfold --profile answers two questions about any prompt payload:
where do the characters go, and what would folding save?
Composition is attributed exactly — the categories sum to the input size — and the
savings come from actually running the encoder, so the profiler can never promise
more than it delivers.
runs entirely in your browser — no upload, no API key
paste something above, or load a sample — then press Profile
example output — recorded run, 300-record JSON API response
$ ctxfold --profile users.json [ctxfold profile] format JSON array — 300 records × 7 fields size 65,614 chars ≈ 16,404 tokens (estimated; pass a tokenizer for exact) where the characters go keys 27% repeated field names (with quotes) syntax 7% braces, brackets, commas, colons values 36% the data itself (with string quotes) whitespace 30% indentation and spacing foldable (lossless, verified by round-trip) fold -66% direct-readable — validated 24/24 vs raw + --dictionary -73% readability tradeoff — off by default, see README verdict: fold it — 16,404 → ~5,595 tokens (~66% fewer)
The panel above runs the real encoder in your browser — same code as the CLI,
no API key, nothing uploaded. Prefer a terminal? npx ctxfold --profile yourfile.json,
or node examples/profile-demo.js after cloning.
benchmarks
Lookup accuracy is scored against exact ground truth: the same questions asked of the folded form and the raw form, across GPT-4o-mini, Claude, Llama, and Qwen. Where the measurement came in against the format, the table says so.
| dataset | lookup, raw | lookup, folded | tokens saved | reading |
|---|---|---|---|---|
| JSON (400 recs) | 24/24 | 24/24 | 39% | direct-readable |
| Logs (1,200 ln) | 23/24 | 23/24 | 39% | direct-readable |
| CSV / TSV (400 recs) | 24/24 | ≤9/24 | 28% | pipeline only |
Table shows the original GPT-4o-mini runs; the full four-model matrix (including
the one model that reads folded CSV correctly) is in the
README.
The CSV result is a published negative: CSV has no syntax to remove, so folding it
factors the data itself — and models don't reliably reconstruct values through a header.
Fold CSV for lossless transit and decompress() before the model reads it; for direct
reading, send CSV raw.
The full story of that measurement →
get it
antrixy/ctxfold
Source, releases, the readability harnesses, and the roadmap.
npmnpm install ctxfold
Zero dependencies, Node ≥ 18, MIT. CLI and programmatic API.
write-upWhy lossless, not lossy
The launch post: the case against summarizing your evidence away.
write-upThe 0/24 result
Testing my own format, the failure it found, and the profiler it produced.