ctxfold tool cuts LLM prompt tokens by 40% on structured data without data loss
A lightweight, dependency-free npm package called ctxfold has been released to reduce token usage when feeding structured data such as logs, JSON, and CSV files into large language models. Unlike semantic compression tools that summarize and discard data, ctxfold re-encodes repetitive structure into a compact, self-labeling format while retaining every byte of the original input. The tool enforces a strict lossless guarantee in code — if it cannot perfectly reconstruct the original input from its compressed output, it returns the original text unchanged. In tests against GPT-4o-mini, responses generated from ctxfold-compressed data matched those from raw input field for field, with token reductions of roughly 35–40% on templated logs and JSON arrays. The MIT-licensed package requires no API calls or external dependencies and is compatible with any LLM provider.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in